-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpro1.cpp
More file actions
185 lines (147 loc) · 6.44 KB
/
Copy pathpro1.cpp
File metadata and controls
185 lines (147 loc) · 6.44 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include<iostream>
#include<iterator>
#include<list>
#define STACKSIZE 10
#define QUEUESIZE 10
using namespace std;
/*
void showList( list < int > g)
{
list <int> :: iterator it ;
it=g.end();
do
{
it--;
cout<<"\n"<< *it ;
}while (it != g.begin() );
}
*/
void showList1( list < int > g)
{
list <int> :: reverse_iterator it ;
it=g.rbegin();
do
{
cout<<"\n"<< *it ;
it++;
}while (it != g.rend() );
}
void showList2( list < int > g)
{
list <int> :: iterator it ;
it=g.begin();
do
{
cout<<"\n"<< *it ;
it++;
}while (it != g.end() );
}
int main()
{
list <int> stack;
list <int> queue;
char ch;
int choice1,choice2,val;
int exit1=1;
int exit2=1;
int exit3=1;
do
{ cout<<"Enter Your Choice\n1]TO PERFORM OPERATION ON STACK\n2]TO PERFORM OPERATION ON QUEUE\n3]TO EXIT\n";
cin>>choice1;
{
switch(choice1)
{
case 1:
{
do
{
cout<<"\n\tStack Operations (MAX SIZE =10)";
cout<<"\n1.Push \n2.Pop \n3.Display Stack\n4.Exit\nEnter Your Choice =";
cin>>choice2;
switch(choice2)
{
case 1 :if(stack.size()==STACKSIZE)
cout<<"\n\tStack is Full";
else
{
cout<<"\nEnter value = ";
cin>>val;
stack.push_back(val);
}
break;
case 2 :if(stack.size()==0)
cout<<"\n\tStack is Empty";
else
{
val=stack.back();
cout<<"\nPoped Element = "<<val;
stack.pop_back();
}
break;
case 3 :if(stack.size()==0)
cout<<"\n\tStack is Empty";
else
{
showList1(stack);
}
break;
case 4 :exit2=0;
break;
default : cout<<"\nWrong Choice !!!!!";
break;
}
}while(exit2!=0);
exit2=1;
}
break;
case 2 :
{
do
{
cout<<"\n\tQueue Operations (MAX SIZE =10)";
cout<<"\n1.Push \n2.Pop \n3.Display Queue\n4.Exit\nEnter Your Choice =";
cin>>choice2;
switch(choice2)
{
case 1 :if(queue.size()==QUEUESIZE)
cout<<"\n\tQueue is Full";
else
{
cout<<"\nEnter value = ";
cin>>val;
queue.push_back(val);
}
break;
case 2 :if(queue.size()==0)
cout<<"\n\tQueue is Empty";
else
{
val=queue.front();
cout<<"\nPoped Element = "<<val;
queue.pop_front();
}
break;
case 3 :if(queue.size()==0)
cout<<"\n\tQueue is Empty";
else
{
showList2(queue);
}
break;
case 4 :exit3=0;
break;
default : cout<<"\nWrong Choice !!!!!";
break;
}
}while(exit3!=0);
exit3=1;
}
break;
case 3 :exit1=0;
break;
default : cout<<"\nWrong Choice !!!!!";
break;
}
}
}while(exit1!=0);
}