-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5091.cpp
More file actions
33 lines (31 loc) · 704 Bytes
/
5091.cpp
File metadata and controls
33 lines (31 loc) · 704 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
#include<iostream>
#include<cstring>
using namespace std;
class MyStack{
private:
int m_array[10];
int m_size;
public:
MyStack():m_size(0){memset(m_array,0,sizeof(m_array));};
void push(int num){m_array[m_size++]=num;}
int pop(){if(m_size!=0){return m_array[--m_size];}}
void print(){cout<<"( ";for(int i=0;i<m_size;i++){cout<<m_array[i]<<" ";}cout<<")";}
};
int main(){
char order;
int num;
MyStack* S = new MyStack;
while(cin>>order){
if(order=='i'){
cin>>num;
S->push(num);
}
if(order=='o'){
S->pop();
}
if(order=='s'){
S->print();
return 0;
}
}
}