#include<bits/stdc++.h>
using namespace std;
const long long N=1e6+10;
unsigned long long x[N],t,n,hz,h;
string cz;
int main(){
cin>>t;
for(int i=0;i<t;i++){
cin>>n;
for(int j=0;j<n;j++){
cin>>cz;
if(cz=="push"){
cin>>h;
x[hz+1]=h;
hz++;
}
else if(cz=="pop"){
if(hz!=0)hz--;
else cout<<"Empty"<<endl;
}
else if(cz=="query"){
if(hz!=0)cout<<x[hz]<<endl;
else cout<<"Anguei!"<<endl;
}
else cout<<hz<<endl;
}
}
return 0;
}
代码