1#include<queue>
2std::priority_queue <int, std::vector<int>, std::greater<int> > minHeap;
1// C++ program to show that priority_queue is by
2// default a Max Heap
3#include <bits/stdc++.h>
4using namespace std;
5
6// Driver code
7int main ()
8{
9 // Creates a max heap
10 priority_queue <int> pq;
11 pq.push(5);
12 pq.push(1);
13 pq.push(10);
14 pq.push(30);
15 pq.push(20);
16
17 // One by one extract items from max heap
18 while (pq.empty() == false)
19 {
20 cout << pq.top() << " ";
21 pq.pop();
22 }
23
24 return 0;
25}
26
1#include <bits/stdc++.h>
2using namespace std;
3
4
5int main ()
6{
7
8 priority_queue <int> pq;
9 pq.push(5);
10 pq.push(1);
11 pq.push(10);
12 pq.push(30);
13 pq.push(20);
14
15
16 while (pq.empty() == false)
17 {
18 cout << pq.top() << " ";
19 pq.pop();
20 }
21
22 return 0;
23}