0分求助 玄关
查看原帖
0分求助 玄关
1159460
juruogcr楼主2024/7/24 12:34
#include<bits/stdc++.h>
using namespace std;
int t,n;string opt;long long x;
stack<int> s;
void solve(){
    scanf("%d",&n);
    while(n--){
        cin>>opt;
        if(opt=="push"){
            scanf("%lld",&x);
            s.push(x);
        }
        else if(opt=="pop"){
            if(s.empty()) printf("Empty\n");
            else s.pop();
        }
        else if(opt=="query"){
            if(s.empty()) printf("Anguei!\n");
            else printf("%lld",s.top());
        }
        else printf("%d",s.size());
    }
}

int main(){
    scanf("%d",&t);
    while(t--) solve();
    return 0;
}
2024/7/24 12:34
加载中...