求助
查看原帖
求助
1235026
haimingbei楼主2024/8/4 16:38

哪有错滴? 错两个,MLE一个,0分

/*
1、B3614 【模板】栈 
*/
#include<bits/stdc++.h>
using namespace std;
stack <int> st;
int main(){
	int t,n,x;
	string s;
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n;
		while(n--){
		cin>>s;
			if(s=="push"){
				cin>>x;
				st.push(x);
			}
			else if(s=="pop"){
				if(!st.empty())st.pop();
				else cout<<"Empty";
			}
			else if(s=="query"){
				if(!st.empty())cout<<st.top()<<endl;
				else cout<<"Anguei!"<<endl;
			}
			else if(s=="size")cout<<st.size()<<endl;
		}
	}
	
	return 0;
}
2024/8/4 16:38
加载中...