-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (37 loc) · 877 Bytes
/
main.cpp
File metadata and controls
41 lines (37 loc) · 877 Bytes
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
// main.cpp
// Dylan Vanmali
// CS130A Spring 2017 Prof. Suri
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include "SplayTree.cpp"
using namespace std;
int main(int argc, char* argv[]) {
string line;
SplayTree<int> *s = new SplayTree<int>;
int lineNum = 0;
int operations = 0;
while( getline( cin, line ) ) {
//cout << line << endl;
if (lineNum == 0) {
operations = atoi(line.c_str());
}
else {
if (line.find("insert ") == 0) {
s->insert(atoi(line.substr(7).c_str()));
}
else if (line.find("delete ") == 0) {
s->deleteValue(atoi(line.substr(7).c_str()));
}
else if (line.find("find ") == 0) {
s->find(atoi(line.substr(5).c_str()));
}
else if (line.find("print") == 0) {
cout << *s;
}
}
lineNum++;
}
return 0;
}