Computer Scientists are Pretty Pessimistic

Tuesday, 1 March 2016

Use of Priority Queue

#include <iostream>
#include <queue>
using namespace std;
int main ()
{
    priority_queue <int> pq;
    int i,val;
    for(i=0;i<10;i++)
    {
        cin>>val;
        pq.push(val);
    }
    while(!pq.empty())
    {
        cout<<pq.top()<<endl;
        pq.pop();
    }
    return 0;
}

No comments:

Post a Comment