CE求救
查看原帖
CE求救
1471193
kkksc24楼主2024/12/2 20:52
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main(){
    stack<ull> st;
    ull b;
    int T,n;
    string tmp;
    cin>>T;
    for(int i=1;i<=T;i++){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>tmp;
            if(tmp=="push"){
                cin>>b;
                st.push(b);
            }
            if(tmp=="pop"){
                if(st.empty) cout<<"Empty"<<endl;
                else st.pop;
            }
            if(tmp=="query"){
                if(st.empty) cout<<"Anguei!"<<endl;
                else cout<<st.top()<<endl;
            }
            if(tmp=="size") cout<<st.size()<<endl;
        }
    }
    return 0;
}
2024/12/2 20:52
加载中...