-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (43 loc) · 890 Bytes
/
main.cpp
File metadata and controls
47 lines (43 loc) · 890 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
42
43
44
45
46
47
#include <iostream>
#include "rbtree.h"
int main() {
using std::cin, std::cout;
RBTree tr;
cout << "Number of nodes: ";
int n, x;
cin >> n;
if (n > 0) {
cout << "Nodes: ";
for (int i = 0; i < n; i++) {
cin >> x;
tr.insert(x);
}
}
char c;
while (true) {
cout << tr << "1. Insert\n2. Erase\n3. Quit\n> ";
cin >> c;
switch (c) {
case '1': {
cout << "Node to insert: ";
cin >> x;
tr.insert(x);
break;
}
case '2': {
cout << "Node to erase: ";
cin >> x;
tr.erase(x);
break;
}
case '3': return 0;
case 'q': return 0;
case 'Q': return 0;
default: break;
}
}
}
/*
18
9 6 17 3 8 16 20 1 4 7 12 19 21 2 5 11 14 18
*/