2,3没过dalao求调
查看原帖
2,3没过dalao求调
1137345
cfm123456楼主2024/1/18 20:45
#include<bits/stdc++.h>

using namespace std;

stack<int>ans;
int main(){
	unsigned long long n;
	cin>>n;
	while(n--){
		unsigned long long x;
		cin>>x;
		for(int i=0;i<x;i++){
			string a;
			cin>>a;
			if(a=="push"){
				long long y;
				cin>>y;
				ans.push(y);
			}
			else if(a=="pop"){
				if(ans.size()==0){
				cout<<"Empty"<<endl;
				}
				else ans.pop();
			}
			else if(a=="query"){
				if(ans.size()==0){
					cout<<"Anguei!"<<endl;
				}
				else{
					cout<<ans.top()<<endl;
				}
			}
			else if(a=="size"){
				cout<<ans.size()<<endl;
			}
		}
	}
	return 0;
}
2024/1/18 20:45
加载中...