fork(1) download
  1. #include<vector>
  2. #include<algorithm>
  3. #include<iostream>
  4. #include<queue>
  5. #include<stack>
  6. #include<functional>
  7. using namespace std;
  8. struct data{
  9.  
  10. int first;
  11. int second;
  12. };
  13. class compare{
  14. public:
  15. bool operator()( data &a ,data &b)
  16. {
  17. if(a.first < b.first) return true;
  18. else false;
  19. }
  20. };
  21.  
  22. int main()
  23. {
  24. priority_queue <data , vector<data>, compare> heap;
  25. data temp2[] = { {5,19},{2,7},{90,9},{12,6} };
  26.  
  27. for(int i = 0; i < 4 ;++i)
  28. {
  29. heap.push(temp2[i]);
  30. }
  31. while(heap.empty() == false)
  32. {
  33. cout<<heap.top().first<<endl;;
  34. heap.pop();
  35. }
  36.  
  37. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
12
5
2
90