蒟蒻33pts求条
查看原帖
蒟蒻33pts求条
953664
chenqile楼主2024/11/7 21:09
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t, n;
    string c;
    stack<int> a;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>n;
        for(int j=0;j<n;j++){
            cin>>c;
            if(c[2]=='s'){
                int q;
                cin>>q;
                a.push(q);
            }
            if(c[2]=='p'){
                if(a.empty()) printf("Empty\n");
                else a.pop();
            }
            if(c[2]=='e'){
                if(a.empty()) printf("Anguei!\n");
                else cout<<a.top()<<endl;
            }
            if(c[2]=='z'){
                cout<<a.size()<<endl;
            }
        }
    }
    return 0;
}
2024/11/7 21:09
加载中...