Pagini recente » Cod sursa (job #1646172) | Cod sursa (job #473636) | Cod sursa (job #934112) | Cod sursa (job #1027021) | Cod sursa (job #2840858)
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
using namespace std;
ifstream f ("algsort.in");
ofstream g ("algsort.out");
struct Compare
{
bool operator() (int x, int y)
{
return x > y;
}
};
int main()
{
priority_queue <int, vector <int>, Compare> PQ;
int n, x;
f >> n;
for (int i = 1; i <= n; i++)
{
f >> x;
PQ.push(x);
}
while (PQ.empty() == false)
{
g << PQ.top() << " ";
PQ.pop();
}
}