-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAda_and_Queue.cpp
More file actions
74 lines (62 loc) · 1.19 KB
/
Ada_and_Queue.cpp
File metadata and controls
74 lines (62 loc) · 1.19 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
/*
back - Print number from back and then erase it
front - Print number from front and then erase it
reverse - Reverses all elements in queue
push_back N - Add element N to back
toFront N - Put element N to front
*/
int main()
{
list<int> mylist ;
int tc ;
string str;
cin>>tc;
while(tc--)
{
cin>>str;
if(str=="toFront")
{
int val ;
cin>>val;
mylist.push_front(val);
}
else
if(str=="push_back")
{
int val ;
cin>>val;
mylist.push_back(val);
}
else
if(str=="reverse")
mylist.reverse();
else
if(str=="front")
{
if(mylist.size()==0)
cout<<"No job for Ada?"<<endl;
else
{
list<int> :: iterator x = mylist.begin();
cout<<*x<<endl;
mylist.pop_front();
}
}
else
if(str=="back")
{
if(mylist.size()==0)
cout<<"No job for Ada?"<<endl;
else
{
list<int> :: iterator x = mylist.end();
cout<<*x<<endl;
mylist.pop_back();
}
}
}
return 0;
}