33分C++代码
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int times;
stack<long long>st;
while(n--) {
cin >> times;
for(int i = 0; i < times; i++) {
string oj;
cin >> oj;
if(oj == "push") {
long long x;
scanf("%lld",&x);
st.push(x);
} else if(oj == "query") {
if(st.size() == 0) {
printf("Anguei!\n");
continue;
}
else printf("%lld\n",st.top());
} else if(oj == "pop") {
if(st.size() == 0) {
printf("Empty\n");
continue;
}
else st.pop();
} else if(oj == "size") {
cout << (long long)(st.size()) << endl;
}
}
}
return 0;
}
有没有大佬告诉我哪里错了......
本蒟蒻委屈地哭......
QAQ