本蒟蒻看到这一题(B3614)之后写的代码如下↓
#include <iostream>
#include <stack>
using namespace std;
int T,n;
string s;
int main(){
cin>>T;
for(int i=0;i<T;i++){
cin>>n;
for(int j=0;j<n;j++){
stack <int> stk;
cin>>s;
if(s=="push"){
int tmp;
cin>>tmp;
stk.push(tmp);
}
else if(s=="query"){
if(stk.empty()) cout<<"Anguei!"<<endl;
else cout<<stk.top()<<endl;
}
else if(s=="pop"){
if(stk.empty()) cout<<"Empty"<<endl;
else stk.pop();
}
else{
cout<<stk.size()<<endl;
}
}
}
return 0;
}
结果发现push()函数根本用不了!
有神犇可以帮帮忙嘛