-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
59 lines (46 loc) · 1.13 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* A0118400X
* Shen Juanli
* for CS3230 PJ2 @NUS
* 2013.10
*
*/
#include <stdio.h>
#include <string>
#include <sstream>
#include <iostream>
#include "RBT.h"
using namespace std;
int main()
{
freopen("in.txt", "r", stdin);
RBT* PhoneBook = new RBT();
int n;
cin >> n;
string line;
stringstream ss;
getline(cin, line); // eat the rest of 1st line
string option;
KeyType name = "";
TelType tel = "";
while(n--)
{
getline(cin, line);
ss.clear();
ss << line;
ss >> option >> name >> tel;
// cout << "current action\t" << line << endl;
switch(option[0])
{
case 'H': cout << "H=" << PhoneBook->Height() << endl; break;
case 'S': cout << PhoneBook->Search(name) << endl; break;
case 'I': PhoneBook->Insert(name, tel); break;
case 'D': PhoneBook->Delete(name); break;
default: break;
}
// PhoneBook->CheckBalance();
// cout <<"option is ["<<option<<"] name is ["<<name<<"] and tel is ["<<tel<<"]"<<endl;
// PhoneBook->Print();
}
return 0;
}