蒙自市凤凰小学又阝十尃亻二 • 1年前
using namespace std; const int n=1e5+5; int a[n],top=0; bool isempty(){
return !top;
} void push(int x){
a[++top]=x;
} int pop(){
if(!isempty())
return a[--top];
} int Top(){
if(!isempty())
return a[top];
} int main(){
int n,x,y;
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
if(x==1){
cin>>y;
push(y);
}else if(x==2){
pop();
}else{
cout<<Top()<<endl;
}
}
return 0;
}
评论:
请先登录,才能进行评论