B3614 WA 33分 求dalao调
查看原帖
B3614 WA 33分 求dalao调
1351155
liuzhuoran141516楼主2024/7/16 16:16
#include <bits/stdc++.h>
using namespace std;
stack<int> zhan;
string s;
int x, t, n;
int main() {
	cin >> t;
	for(int i = 1; i <= t; i ++) {
		cin >> n;
		for(int j = 1; j <= n; j ++) {
			cin >> s;
			if(s == "push") {
				cin >> x;
				zhan.push(x);
			} else if(s == "pop") {
				if(!zhan.empty()) {
					zhan.pop();
				} else {
					cout << "Empty" << endl;
				}
			} else if(s == "query") {
				if(!zhan.empty()) {
					cout << zhan.top() << endl;
				} else {
					cout << "Anguei!" << endl;
				}
			} else {
				cout << zhan.size() << endl;
			}
		}
	}
	return 0;
}
2024/7/16 16:16
加载中...