33分求助
查看原帖
33分求助
400468
Aakkosetsumussa楼主2023/6/30 16:49
#include<bits/stdc++.h>
using namespace std;
typedef long long inr;
typedef unsigned long long unr;
#define fur(y) for(inr i=1;i<=y;i++)
#define fru(i,s,e) for(inr i=s;i<=e;i++)
#define frd(i,s,e) for(inr i=s;i>=e;i--)
#define el <<endl
#define sp <<" "<<
inr n,m,k,h,r,x,z,y,T,sum=0,ans=0,c;
int main() {
	ios::sync_with_stdio(false);
	cin>>T;
	while(T--) {
		cin>>n;
		stack<int> s;
		for(int i=1; i<=n; i++) {
			string str;
			cin>>str;
			if(str=="push") {
				cin>>x;
				s.push(x);
			} else if(str=="query") {
				if(!s.empty()) cout<<s.top()<<endl;
				else cout<<"Anguei!"<<endl;
			} else if(str=="size") {
				cout<<s.size()<<endl;
			} else {
				if(!s.empty()) s.pop();
				else cout<<"Empty"<<endl;
			}
		}
	}
	return 0;
}

2023/6/30 16:49
加载中...