Pagini recente » Cod sursa (job #2536816) | Cod sursa (job #446436) | Cod sursa (job #3218676) | Cod sursa (job #2144187) | Cod sursa (job #1241241)
#include <fstream>
#include <iterator>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ifstream fin("algsort.in");
ofstream fout("algsort.out");
int n; fin >> n;
vector<int> V(n);
copy(istream_iterator<int>(fin), istream_iterator<int>(), V.begin());
make_heap(V.begin(), V.end());
sort_heap(V.begin(), V.end());
copy(V.begin(), V.end(), ostream_iterator<int>(fout, " "));
fout << endl;
return 0;
}