Cod sursa(job #710713)
| Utilizator | Data | 10 martie 2012 16:52:30 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <stdio.h>
#include <vector>
#include <algorithm>
std::vector<int> v;
bool cmp(int a,int b){if(a>b)return true; else return false;}
int main(){
int n,i,x;
freopen("algsort.in","r",stdin);
freopen("algsort.out","w",stdout);
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&x);
v.push_back(x);
push_heap(v.begin(),v.end(),cmp); }
for(i=0;i<n;i++){
printf("%d ",v[0]);
pop_heap(v.begin(),v.end(),cmp);
v.pop_back();}
}
