Cod sursa(job #1850740)

Utilizator teo.cons98Constantin Teodor-Claudiu teo.cons98 Data 18 ianuarie 2017 21:18:35
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
 //sortare cu heapsort
 #include<iostream>
 #include<fstream>
 #include<queue>
 using namespace std;
 ifstream fin("algsort.in");
 ofstream fout("algsort.out");
 struct comparare
 {
   bool operator()(const int& l, const int& r)
   {
       return l > r;
   }
 };

 int main()
 {
     priority_queue<int,vector<int>, comparare > pq;
     int n, x;
     fin>>n;
     for(int i = 1; i <= n; ++i)
     {
         fin>>x;
         pq.push(x);
     }
     while(!pq.empty())
     {
         fout<<pq.top()<<" ";
         pq.pop();
     }
 }