题解 | #堆栈的使用#
堆栈的使用
https://www.nowcoder.com/practice/e91982a145944ceab6bb9a4a508e0e26
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while(cin>>n){
stack<int>stk;
while(n--){
string s1,s2;
cin>>s1;
if(s1=="P"){
cin>>s2;
stk.push(stoi(s2));
}else{
if(s1=="A"){
if(stk.size()==0)cout<<"E"<<endl;
else cout<<stk.top()<<endl;
}else{
if(stk.size()!=0)stk.pop();
}
}
}
}
}
// 64 位输出请用 printf("%lld")
