66pts 求调
查看原帖
66pts 求调
1357615
liujunyua楼主2024/10/7 20:27
#include<iostream>
#include<string>
#include<stack>
using namespace std;
stack<unsigned   long long > st;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T;
    cin>>T;
    while(T--){
    	int n;
    	cin>>n;
    	while(n--){
    		string od;
    		unsigned long long x;
    		cin>>od;
    		if(od=="push"){
    			cin>>x;
    			st.push(x);
			}
			if(od=="pop"){
				if(!st.empty())
				  st.pop();
				else
				  cout<<"Empty"<<'\n';
			}
			if(od=="query"){
				if(!st.empty()) 
				cout<<st.top()<<'\n';
				else
				cout<<"Anguei!"<<'\n';
			}	
			if(od=="size")
			   cout<<st.size()<<'\n';
		}
	}
	return 0;
}

模板栈 总是wa一点 66pts 求调

2024/10/7 20:27
加载中...