蒟蒻求助
查看原帖
蒟蒻求助
1049413
QAQvQAQ楼主2023/12/15 21:51
#include<bits/stdc++.h>
using namespace std;
unsigned long long T,n;
int main(){
	cin>>T;
	while(T--){
		stack<unsigned long long> s;
		cin>>n;
		while(n--){
			string q;
			cin>>q;
			if(q=="push"){
				unsigned long long a;
				cin>>a;
				s.push(a);
				cout<<a<<endl;
			}else if(q=="query"){
				if(!s.empty()){
					cout<<s.top()<<endl;
				}else{
					cout<<"Anguei!"<<endl;
				}
			}else if(q=="size"){
				cout<<s.size()<<endl;
			}else if(q=="pop"){
				if(!s.empty()){
					s.pop();
				}else{
					cout<<"Empty"<<endl;
				}
			}
		}
	}
    return 0;
}
2023/12/15 21:51
加载中...