求助!
查看原帖
求助!
1638686
yckwt楼主2025/1/23 15:16

求助!

请各位大佬看看怎么回事,才33分

#include <bits/stdc++.h>
using namespace std;
stack <int> jundan;
int a, b;
unsigned long long c;
string t;

int main() {
	cin >> a;
	for (int i = 1; i <= a; i++) {
		cin >> b;
		while (!jundan.empty())
			jundan.pop();
		for (int j = 1; j <= b; j++) {
			cin >> t;
			if (t == "push") {
				cin >> c;
				jundan.push(c);
			}
			if (t == "pop") {
				if (jundan.empty() == 0) {
					jundan.pop();
				} else {
					cout << "Empty" << endl;
				}
			}
			if (t == "query") {
				if (jundan.empty() == 0) {
					cout << jundan.top() << endl;
				} else {
					cout << "Anguei!" << endl;
				}
			}
			if (t == "size") {
				cout << jundan.size() << endl;
			}
		}
	}
	return 0;
}

2025/1/23 15:16
加载中...