求助,33分
查看原帖
求助,33分
1073732
hlz2012楼主2024/4/7 22:22
#include<bits/stdc++.h>
using namespace std;
stack<unsigned long long int> s;
int t,n,a[100005],p=1,bo=1,b,x,sum;
string c;
int main(){
	cin>>t;
	for (int i=1;i<=t;i++){
		cin>>n;
		while (s.size()) s.pop();
		for (int j=1;j<=n;j++) {
			cin>>c;
			if (c=="push") {
				cin>>x;
				s.push(x);
			}
			else if (c=="query"){
				if (s.size()==0) cout<<"Anguei!"<<endl;
				else cout<<s.top()<<endl;
			}
			else if (c=="pop"){
				if (s.size()==0) cout<<"Empty"<<endl;
				else s.pop();
			}
			else cout<<s.size()<<endl;
		}
	}
} 
2024/4/7 22:22
加载中...