求助!WA
查看原帖
求助!WA
540870
Yzmddsw楼主2022/8/16 16:31
#include<iostream>
#include<cstdio>
#include<string>
#include<stack>
using namespace std;
int main(){
	int T,n;
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		stack<unsigned long long> a;
		while(n--){
			string b;
			cin>>b;
			if(b=="push"){
				unsigned long long x;
				scanf("%lld",&x);
				a.push(x);
			}
			else if(b=="pop"){
				if(a.empty())cout<<"Empty"<<endl;
                else a.pop();
			}
			else if(b=="query"){
				if(a.empty())cout<<"Anguei!"<<endl;
				else cout<<a.top()<<endl;
			}
			else cout<<a.size()<<endl;
		}
	}
	return 0;
}
2022/8/16 16:31
加载中...