Cod sursa(job #2283988)

Utilizator Andreiii500Andrei Andreiii500 Data 16 noiembrie 2018 12:38:26
Problema Sortare prin comparare Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include<iostream>
#include<fstream>
#include<bits/stdc++.h>
using namespace std;

ifstream in("algsort.in");
ifstream out("algsort.out");

class compare{
public:
    bool operator()(int a, int b){
        return a>b;
        /*if(a%2 != b%2) /// Different parities
            if(a%2 == 1) return 1; /// a is odd, b is even
            else return 0; /// a is even, b is odd
        else /// Same parities
            return a>b;*/
    }
};

int main()
{
    priority_queue<int, vector<int>, compare> v;

    int n;
    in>>n;
    while(n--){
        int nr;
        in>>nr;
        //cout<<"nr = "<<nr<<"\n";
        v.push(nr);
    }

    while(!v.empty()){
        cout<<v.top()<<" ";
        v.pop();
    }

    return 0;
}