-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathds-stl-queue.cpp
53 lines (40 loc) · 1.1 KB
/
ds-stl-queue.cpp
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
45
46
47
48
49
50
51
52
53
#include<iostream>
#include <queue>
using namespace std;
// define the STL queue conntainer which will contain integers
queue<int>Q;
int main(void)
{
freopen("ds-stl-queue.input", "r", stdin);
int T, tcase=1, N, num;
cin>>T;
while(T--) {
cin>>N;
for(int i = 0; i < N; ++i){
cin>>num;
Q.push(num);
}
cout<<"#"<<tcase++<<endl;
// now let's have some fun!
cout<<"size of Queue "<<Q.size()<<endl;
cout<<"front element = "<<Q.front()<<endl;
cout<<"rear element = "<<Q.back()<<endl;
Q.pop();
cout<<"popped\n";
Q.pop();
cout<<"popped\n";
Q.pop();
cout<<"popped\n";
cout<<"size of Queue "<<Q.size()<<endl;
cout<<"front element = "<<Q.front()<<endl;
cout<<"rear element = "<<Q.back()<<endl;
cout<<"printing all elements until queue is empty\n";
while(!Q.empty()) {
cout<<Q.front()<<" ";
Q.pop();
}
cout<<endl;
cout<<"size of Queue "<<Q.size()<<endl;
}
return 0;
}