-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.cpp
More file actions
50 lines (46 loc) · 896 Bytes
/
Copy pathstack.cpp
File metadata and controls
50 lines (46 loc) · 896 Bytes
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>
using namespace std;
class stackk{
public:
int sp=-1;
string arr[5];
void push(string n){
if (sp==4){
cout<<"stack is full\n";
}
else{
sp++;
arr[sp]=n;
}
}
void pop(){
if(sp==-1){
cout<<"stack is empty\n";}
else{
cout<<"pop \""<<arr[sp]<<"\""<<endl;
sp--;
}
}
void show(){
if(sp==-1){
cout<<"stack is empty\n";
}
else{
for(int i=0;i<=sp;i++){
cout<<"item "<<i<<" = "<<arr[i]<<endl;
}
}
}
};
int main(){
stackk ss;
ss.push("mo");
ss.pop();
ss.push("as");
ss.push("sa");
ss.push("saf");
ss.push("sadf");
ss.push("asfrg");
ss.show();
return 0;
}