Cod sursa(job #1014166)

Utilizator tudorv96Tudor Varan tudorv96 Data 22 octombrie 2013 12:09:32
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.4 kb
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

ifstream fin ("algsort.in");
ofstream fout ("algsort.out");

vector <int> v;
int n;

int main() {
	fin >> n;
	while (n--) {
		int x;
		fin >> x;
		v.push_back (x);
	}
	make_heap (v.begin(), v.end());
	sort_heap (v.begin(), v.end());
	for (vector <int> :: iterator it = v.begin(); it != v.end(); ++it)
		fout << *it << " ";
}