zzh
2024-08-05 16:07:06
发布于:广东
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
stack<int>st;
while(n--){
string s;
cin>>s;
if(s=="push"){
int x;
cin>>x;
st.push(x);
}else{
if(!st.empty()) st.pop();
}
}
while(!st.empty()){
cout<<st.top()<<" ";
st.pop();
}
return 0;
}
这里空空如也
有帮助,赞一个