Cod sursa(job #1109163)
| Utilizator | Data | 16 februarie 2014 19:43:37 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
ifstream f("algsort.in");
ofstream g("algsort.out");
int n, x;
f>>n;
vector<int> v;
while(f>>x)v.push_back(x);
//sort(v.begin(), v.end());
make_heap(v.begin(), v.end());
sort_heap(v.begin(), v.end());
vector<int>::iterator it;
it=v.begin();
while(it!=v.end())
g<<*it++<<" ";
return 0;
}
