我用的STL
#include<bits/stdc++.h>
using namespace std;
int main() {
string a;
stack<int> b;
int c;
int n, m;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> m;
for (int j = 0; j < m; j++) {
cin >> a;
if (a == "push") {
cin >> c;
b.push(c);
} else if (a == "pop") {
if (b.empty()) {
cout << "Empty" << endl;
} else {
b.pop();
}
} else if (a == "query") {
if (b.empty()) {
cout << "Anguei!" << endl;
} else {
cout << b.top() << endl;
}
} else if (a == "size") {
cout << b.size() << endl;
}
}
}
return 0;
}