-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.cpp
More file actions
44 lines (35 loc) · 745 Bytes
/
queue.cpp
File metadata and controls
44 lines (35 loc) · 745 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
35
36
37
38
39
40
41
42
43
44
// Queue
#include <iostream>
#include <queue>
using namespace std;
void printq(queue<int> q){
queue<int> qcopy = q;
while(!qcopy.empty()){
cout << " \t " << qcopy.front();
qcopy.pop();
}
cout << '\n';
}
int main()
{
queue<int> qq;
qq.push(6);
qq.push(4);
qq.push(1);
printq(qq);
cout << "\n queue.size() : " << qq.size();
cout << "\n queue.front() : " << qq.front();
cout << "\n queue.back() : " << qq.back();
cout << "\n queue.pop() ";
qq.pop();
printq(qq);
return 0;
}
// g++ queue.cpp -o queue.out
// ./queue.out
//output
// 6 4 1
// queue.size() : 3
// queue.front() : 6
// queue.back() : 1
// queue.pop() 4 1