Pagini recente » Cod sursa (job #1782114) | Cod sursa (job #1035472) | Istoria paginii runda/cnrvxa1/clasament | Cod sursa (job #2414770) | Cod sursa (job #1014166)
#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 << " ";
}