蒟蒻33分求助 玄关
查看原帖
蒟蒻33分求助 玄关
947854
ztyo_zysclown楼主2023/8/21 15:58
#include<bits/stdc++.h>
using namespace std;
string a;
unsigned long long n;
unsigned long long o;
int main(){
	cin>>n;
	while(n--){
	    stack<unsigned long long> s;
		cin>>o;
		while(o--){
			cin>>a;
			if(a=="push"){
				int X;
				cin>>X;
				s.push(X);
			}
			if(a=="pop"){
				if(s.empty()==1){
					cout<<"Empty"<<endl;
				}
				else{
					s.pop();
				}
			}
			if(a=="query"){
				if(s.empty()==1){
					cout<<"Anguei!"<<endl;
				}
				else{
					cout<<s.top()<<endl;
				}
			}
			if(a=="size"){
				cout<<s.size()<<endl;
			}
		}
	}
	return 0;
}
2023/8/21 15:58
加载中...