-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
88 lines (86 loc) · 2.32 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include "Heap.h"
#include "BinomialHeap.h"
#include "FibonacciHeap.h"
int main() {
std::cout << "Choose heap to use: (h/b/f)";
std::string dec;
std::cin >> dec;
if (dec == "h") {
Heap<int> h;
while (true) {
std::cout << "Heap $ ";
std::cin >> dec;
if (dec == "insert") {
int x;
std::cin >> x;
h.insert(x);
}
else if (dec == "extract_min") {
std::cout << h.extract_min() << std::endl;
}
else if (dec == "get_min") {
std::cout << h.get_min() << std::endl;
}
else if (dec == "exit") {
return 0;
}
else {
std::cout << "Unknown command" << std::endl;
}
}
}
else if (dec == "b") {
BinomialHeap<int> h;
while (true) {
std::cout << "BinomialHeap $ ";
std::cin >> dec;
if (dec == "insert") {
int x;
std::cin >> x;
h.insert(x);
}
else if (dec == "extract_min") {
std::cout << h.extract_min() << std::endl;
}
else if (dec == "get_min") {
std::cout << h.get_min() << std::endl;
}
else if (dec == "exit") {
return 0;
}
else {
std::cout << "Unknown command" << std::endl;
}
}
}
else if (dec == "f") {
FibonacciHeap<int> h;
while (true) {
std::cout << "FibonacciHeap $ ";
std::cin >> dec;
if (dec == "insert") {
int x;
std::cin >> x;
h.insert(x);
}
else if (dec == "extract_min") {
std::cout << h.extract_min() << std::endl;
}
else if (dec == "get_min") {
std::cout << h.get_min() << std::endl;
}
else if (dec == "exit") {
return 0;
}
else {
std::cout << "Unknown command" << std::endl;
}
}
}
else {
std::cout << "Unknown heap" << std::endl;
return 0;
}
return 0;
}