CPP 29
PQc Guest on 2nd May 2021 11:50:59 PM
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.    priority_queue<int> mx; // max-heap priority queue
  7.    //inserting elements
  8.    mx.push(10);
  9.    mx.push(30);
  10.    mx.push(20);
  11.    mx.push(5);
  12.    mx.push(1);
  13.  
  14.    int top_element=mx.top();
  15.  
  16.    cout<<"value of top element: "<<top_element<<endl;
  17.  
  18.    cout<<"list of elements: ";
  19.  
  20.    while(mx.size()!=0){
  21.        cout<<mx.top()<<" ";
  22.        mx.pop();
  23.    }
  24.  
  25.  
  26.    return 0;
  27. }

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.