fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.  
  8. priority_queue<int>maxHeap;
  9. maxHeap.push(10);
  10. maxHeap.push(5);
  11. maxHeap.push(20);
  12. maxHeap.push(15);
  13.  
  14. // while(maxHeap.size() > 0)
  15. // {
  16. // cout<<maxHeap.top()<<endl;
  17. // maxHeap.pop();
  18. // }
  19.  
  20. priority_queue<int, vector<int>, greater<int> >minHeap;
  21. minHeap.push(20);
  22. minHeap.push(2);
  23. minHeap.push(15);
  24. minHeap.push(5);
  25.  
  26. while(minHeap.size() > 0)
  27. {
  28. cout<<minHeap.top()<<endl;
  29. minHeap.pop();
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36. // vector<vector<int> >v;
  37.  
  38. // vector<int>v[10];
  39. // for(int i = 0; i < 10 ; i++)
  40. // {
  41. // v[i].push_back(5);
  42. // }
  43. // for(int i = 0; i < 10; i++)
  44. // {
  45. // for(int j = 0; j < v[i].size(); j++)
  46. // {
  47. // cout<<v[i][j]<<" ";
  48. // }
  49. // cout<<endl;
  50. // }
  51.  
  52. // vector<int>v; // 1D Array // Dynamic //created through Linked list but acts like an array
  53. // v.push_back(5);
  54. // v.push_back(10);
  55. //
  56. // for(int i = 0; i < v.size(); i++)
  57. // {
  58. // cout<<v[i]<<" ";
  59. // }
  60.  
  61. }
  62.  
Success #stdin #stdout 0.01s 5328KB
stdin
Standard input is empty
stdout
2
5
15
20