Cod sursa(job #1206319)
| Utilizator | Data | 9 iulie 2014 16:41:58 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("algsort.in");
ofstream fout("algsort.out");
vector < int > V;
int main()
{
int n, x;
fin >> n;
for (int i=0; i<n; i++)
{
fin >> x;
V.push_back(x);
}
make_heap(V.begin(), V.end());
sort_heap(V.begin(), V.end());
for (int i=0; i<n; i++) fout << V[i] << ' ';
fout.close();
return 0;
}
