help,WA2,3点
查看原帖
help,WA2,3点
878137
_QWQ__QWQ_楼主2023/3/14 21:34
#include<bits/stdc++.h>
using namespace std;
string caozuo;
int num,t,n,b;
stack<int> a;
int main(){
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>n;
        for(int j=1;j<=n;j++){
            cin>>caozuo;
            if(caozuo=="push"){
                cin>>num;
                a.push(num);
            }
            if(caozuo=="pop"){
                if(a.empty()){
                    cout<<"Empty"<<endl;
                }
                else{
                    a.pop();
                }
            }
            if(caozuo=="query"){
                if(a.empty()){
                    cout<<"Anguei!"<<endl;
                }
                else{
                    cout<<a.top()<<endl;
                }
            }
            if(caozuo=="size"){
                cout<<a.size()<<endl;
            }
        }
    }
    return 0;
}
2023/3/14 21:34
加载中...