-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (44 loc) · 837 Bytes
/
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
//
// main.cpp
// HeapInPlace
//
// Created by Maksim Piriyev on 02.04.21.
//
#include <stdio.h>
#include "heap.h"
class test{
public:
int d = 0;
test(){}
test(int d):d(d){}
bool operator < (const test& t){ return d < t.d;}
};
int main(int argc, const char * argv[]) {
heap<int> h;
// 1 , 2 , 3 , 4 , 5 , 6 , 7
for(int i=10;i>=0;i--){
h.push(i);
}
// for(int i=0;i<10;i++){
// h.push(i);
// }
// h.push(0);
// h.push(1);
// h.push(2);
while(h.size()){
int t = h.top();
h.pop();
printf("%d, ",t);
}
printf("\n");
heap<test> h2;
for(int i=10;i>=0;i--){
h2.push(test(i));
}
while(h2.size()){
auto t = h2.top();
h2.pop();
printf("%d, ",t.d);
}
return 0;
}