Pagini recente » Cod sursa (job #793679) | Cod sursa (job #1573224) | Cod sursa (job #1775376) | Cod sursa (job #1567414) | Cod sursa (job #1850740)
//sortare cu heapsort
#include<iostream>
#include<fstream>
#include<queue>
using namespace std;
ifstream fin("algsort.in");
ofstream fout("algsort.out");
struct comparare
{
bool operator()(const int& l, const int& r)
{
return l > r;
}
};
int main()
{
priority_queue<int,vector<int>, comparare > pq;
int n, x;
fin>>n;
for(int i = 1; i <= n; ++i)
{
fin>>x;
pq.push(x);
}
while(!pq.empty())
{
fout<<pq.top()<<" ";
pq.pop();
}
}