keymasterviriya1150

Untitled

Sep 8th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>  
  2.  #include <queue>  
  3.  using namespace std;  
  4.  
  5.  struct compare  
  6.  {  
  7.    bool operator()(const int& l, const int& r)  
  8.    {  
  9.        return l > r;  
  10.    }  
  11.  };  
  12.  
  13.  int main()  
  14.  {  
  15.      priority_queue<int,vector<int>, compare > pq;  
  16.  
  17.      pq.push(3);  
  18.      pq.push(5);  
  19.      pq.push(1);  
  20.      pq.push(8);  
  21.      while ( !pq.empty() )  
  22.      {  
  23.          cout << pq.top() << endl;  
  24.          pq.pop();  
  25.      }  
  26.      cin.get();  
  27.  }
Advertisement
Add Comment
Please, Sign In to add comment