Cod sursa(job #1850816)
| Utilizator | Data | 18 ianuarie 2017 22:30:20 | |
|---|---|---|---|
| Problema | Statistici de ordine | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
//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();
}
}
