66分求调
查看原帖
66分求调
1100674
Mountains_OIer楼主2024/6/9 19:44

66分求调!

#include<bits/stdc++.h>
#include<stack>
using namespace std;
int n,t;
string num;
stack<unsigned long long> s;
int main(){
    cin >> t;
    for(int i=1;i<=t;i++){
    	cin>>n;
    	for(int j=1;j<=n;j++){
        	unsigned long long x;
        	cin>>num;
        	if (num=="push"){
        		cin>>x;
				s.push(x);
			}else if(num=="pop"){
            	if(s.empty()){
            		cout<<"Empty"<<endl;
				}else{
            		s.pop();
				} 
        	}else if(num=="query"){
        	    if(s.empty()){
        	    	cout<<"Anguei!"<<endl;
				}else{
					cout<<s.top()<<endl;
				}
        	}else{
        		cout<<s.size()<<endl;
			}
    	}
    }
    return 0;
}
2024/6/9 19:44
加载中...