#include <iostream>
#include <queue>
#include <functional>
using namespace std;
void heapSort
(int a
[],
int n
);
int main
(){
int a
[4] =
{7,
2,
4,
9};
priority_queue <int, vector<int>, greater<int> > h;
heapSort
(a,
4);
for (int i =
0; i <
4; i++
){
cout << a
[i
] << endl;
}
return 0;
}
void heapSort
(int a
[],
int n
){
priority_queue <int, vector<int>, greater<int> > h;
int x, k;
for (int i =
0; i < n; i++
){
x = a
[i
];
h.
push(x
);
}
k =
0;
while (!h.
empty()){
x = h.
top(); h.
pop();
a
[k
] = x;
k++;
}
}