全红
查看原帖
全红
1349478
tangyiqi楼主2025/2/8 12:18
#include <bits/stdc++.h>
using namespace std;
stack<int>a;
string order;
int t;
int main() {
	scanf("%d",&t);
	while(t--){
		cin>>order;
		if(order == "push"){
			int x;
			scanf("%d\n",&x);
			a.push(x);
		}
		else if(order == "pop"){
			if(a.empty())printf("Empty\n");
			else a.pop();
		}
		else if(order == "query"){
			if(a.size() == 0)printf("Anguei!\n");
			else printf("%d\n",a.top());
		}
		else printf("%d",a.size());
		int x = a.size();
		while(x--)a.pop();
	}
	return 0;
}
2025/2/8 12:18
加载中...