help me!!玄关
查看原帖
help me!!玄关
902351
Little_x_starTYJ楼主2023/11/4 16:35
#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--) {
		stack<unsigned long long> s;
		int n;
		scanf("%d", &n);
		while (n--) {
			string a;
			cin >> a;
			if (a == "push") {
				unsigned long long x;
				cin >> x;
				s.push(x);
			} else if (a == "query") {
				if (s.empty())
					puts("Anguei!");
				else
					printf("%d\n", s.top());
			} else if (a == "size")
				printf("%d\n", s.size());
			else if (a == "pop") {
				if (s.empty())
					puts("Empty");
				else
					s.pop();
			}

		}

	}

}

33分

2023/11/4 16:35
加载中...