代码如下:
#include<bits/stdc++.h>
using namespace std;
stack<int> s;
int T;
int n;
string t;
int x;
int main()
{
scanf("%d",&T);
while(T--)
{
while(!s.empty()) s.pop();
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
cin>>t;
if(t=="push")
{
cin>>x;
s.push(x);
}
if(t=="pop")
{
if(!s.empty())
s.pop();
else
cout<<"Empty"<<endl;
}
if(t=="query")
{
if(!s.empty())
cout<<s.top()<<endl;
else
cout<<"Anguei!"<<endl;
}
if(t=="size") cout<<s.size()<<endl;
}
}
return 0;
}
33分求调?