why
查看原帖
why
1340578
piyuhan666楼主2024/9/12 17:46
#include<bits/stdc++.h>
using namespace std;
int s,t;
stack <long long> stk;
int n;
int main(){
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n;
		for(int j=1;j<=n;j++){
			string v;
			cin>>v;
			if(v=="push"){
				long long b;
				cin>>b;
				stk.push(b);
			}
			else if(v=="pop"){
				if(stk.size()){
					stk.pop();
				}
				else{
					cout<<"Empty"<<endl;
				}
			}
			else if(v=="size"){
				cout<<stk.size()<<endl;
			}
			else if(v=="query"){
				if(stk.size()){
					cout<<stk.top()<<endl;
				}
				else{
					cout<<"Anguei!"<<endl;
				}
			}
		} 
	}
	return 0;
} 
2024/9/12 17:46
加载中...