-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathStack_Stl.cpp
50 lines (50 loc) · 1.2 KB
/
Stack_Stl.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
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
stack<int> st;
int choice, item;
while (1)
{
cout<<"\n---------------------"<<endl;
cout<<"Stack Implementation in Stl"<<endl;
cout<<"\n---------------------"<<endl;
cout<<"1.Insert Element into the Stack"<<endl;
cout<<"2.Delete Element from the Stack"<<endl;
cout<<"3.Size of the Stack"<<endl;
cout<<"4.Top Element of the Stack"<<endl;
cout<<"5.Exit"<<endl;
cout<<"Enter your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter value to be inserted: ";
cin>>item;
st.push(item);
break;
case 2:
item = st.top();
st.pop();
cout<<"Element "<<item<<" Deleted"<<endl;
break;
case 3:
cout<<"Size of the Queue: ";
cout<<st.size()<<endl;
break;
case 4:
cout<<"Top Element of the Stack: ";
cout<<st.top()<<endl;
break;
case 5:
exit(1);
break;
default:
cout<<"Wrong Choice"<<endl;
}
}
return 0;
}