-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack_and_Queue_using_DEQueue-STL.cpp
More file actions
59 lines (49 loc) · 1.38 KB
/
Copy pathStack_and_Queue_using_DEQueue-STL.cpp
File metadata and controls
59 lines (49 loc) · 1.38 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
deque<int> d;
int choice, data;
while (1)
{
cout << endl;
cout << "1. To enter data into stack." << endl;
cout << "2. To enter data into queue." << endl;
cout << "3. To delete data from stack." << endl;
cout << "4. To delete data from queue." << endl;
cout << "5. To display the dequeue data." << endl;
cout << "6. TO EXIT." << endl;
cout << "\nENTER YOUR CHOICE... : ";
cin >> choice;
switch (choice)
{
case 1:
cout << "\nEnter the number to be inserted (STACK): ";
cin >> data;
d.push_front(data);
break;
case 2:
cout << "\nEnter the number to be inserted (QUEUE) : ";
cin >> data;
d.push_back(data);
break;
case 3:
cout << "\nDeleted element (STACK) : " << d.front();
d.pop_front();
break;
case 4:
cout << "\n Deleted element (QUEUE) : " << d.back();
d.pop_back();
break;
case 5:
for (auto i = d.begin(); i != d.end(); i++)
cout << *i << " ";
break;
case 6:
exit(0);
break;
default:
cout << "\nINVALID CHOICE..." << endl;
}
}
}