-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (41 loc) · 1013 Bytes
/
Copy pathmain.cpp
File metadata and controls
59 lines (41 loc) · 1013 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
48
49
50
51
52
53
54
55
56
57
58
59
#include <string>
#include <iostream>
#include "intset.h"
using namespace std;
int main(void)
{
Intset I;
string command;
int key;
while(1) {
cin >> command;
if (cin.eof()) break;
if (command == "insert") {
cin >> key;
if (I.find(key))
cout << "Error! Key " << key << " already in structure!\n";
else
I.insert(key);
} else if (command == "remove") {
cin >> key;
if (!I.find(key))
cout << "Error! Key " << key << " not in structure!\n";
else
I.remove(key);
} else if (command == "find") {
cin >> key;
if (I.find(key))
cout << "Key " << key << " present.\n";
else
cout << "Key " << key << " absent.\n";
} else if (command == "print") {
cout << "Contents of structure in sorted order:\n";
I.print();
} else if (command == "quit") {
break;
} else {
cout << "Error! Unknown command '" << command << "'!\n";
}
}
return 0;
}