forked from larissalages/code_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriorityQueue.cpp
More file actions
34 lines (27 loc) · 824 Bytes
/
PriorityQueue.cpp
File metadata and controls
34 lines (27 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <queue>
using namespace std;
void showPriQueue(priority_queue <int> pri_queue) {
while (!pri_queue.empty()){
cout << pri_queue.top()<<" ";
pri_queue.pop();
}
}
int main (){
priority_queue <int> myqueue;
int number_values;
cout << "Enter the total number of element: ";
cin >> number_values;
for (int index = 0; index < number_values; index++) {
myqueue.push(index);
}
cout << "Values in myqueue : ";
showPriQueue(myqueue);
cout << "\nSize of myqueue : " << myqueue.size() << endl;
cout << "First element of the myqueue : " << myqueue.top() << endl;
cout << "Pop element from myqueue ";
myqueue.pop();
cout << "\nValues in myqueue after pop : ";
showPriQueue(myqueue);
return 0;
}