Files
Data-Structure/BinaryTree/priorityQueue/maxHeap/main.cpp
2025-08-09 19:23:37 +08:00

78 lines
841 B
C++

#include "maxHeap.h"
using namespace std;
int main() {
maxHeap<int> h;
h.push(9);
h.push(8);
h.push(7);
h.push(6);
h.push(5);
h.push(4);
h.push(3);
h.push(2);
h.push(1);
h.display();
/*
* 9
* 8 7
* 6 5 4 3
* 2 1
*/
h.push(10);
h.display();
h.push(11);
h.display();
h.push(12);
h.display();
/*
* 12
* 10 11
* 6 9 7 3
* 2 1 5 8 4
*/
h.pop();
h.display();
h.pop();
h.display();
h.pop();
h.display();
return 0;
}
/*
输出结果与预测的一致
9
8 7
6 5 4 3
2 1
10
9 7
6 8 4 3
2 1 5
11
10 7
6 9 4 3
2 1 5 8
12
10 11
6 9 7 3
2 1 5 8 4
11
10 7
6 9 4 3
2 1 5 8
10
9 7
6 8 4 3
2 1 5
9
8 7
6 5 4 3
2 1
*/