90pts求调
查看原帖
90pts求调
1663524
Tianwei_Zhao楼主2025/8/5 13:06
#include<bits/stdc++.h>
using namespace std;

string op;
unsigned long long x,t,n;
stack<unsigned long long> s;

int main(){
    cin >> t;
    for(unsigned long long i=0;i<t;i++){
        cin >> n;
        for(unsigned long long j=0;j<n;j++){
            cin >> op;
            if(op == "push"){
                cin >> x;
                s.push(x);
            }else if(op == "size"){
                cout << s.size() << "\n";
            }else if(op == "pop"){
                if(!s.empty()){
                    s.pop();
                }else{
                    cout << "Empty" << "\n";
                }
            }else if(op == "query"){
                if(!s.empty()){
                    cout << s.top() << "\n";
                }else{
                    cout << "Anguei!" << "\n";
                }
            }
        }
    }
    return 0;
}
2025/8/5 13:06
加载中...