66分WA了一个点 求看看哪里有问题
查看原帖
66分WA了一个点 求看看哪里有问题
116297
xinchenxiao楼主2024/9/26 12:28

因为不知道为什么没办法下载输入数据 所以无从检查 各路大佬帮忙看看

#include <iostream>
#include <stack>
#include <string>
using namespace std;

stack<unsigned long long int> a;

void c(int n) {
    for (int i = 0; i < n; i++) {
        string operation;
        cin >> operation;
        if (operation == "push") {
            unsigned long long int x;
            cin >> x;
            a.push(x);
        }
        else if (operation == "pop") {
            if (a.empty()) {
                cout << "Empty" << endl;
            }
            else {
                a.pop();
            }
        }
        else if (operation == "query") {
            if (a.empty()) {
                cout << "Anguei!" << endl;
            }
            else {
                cout << a.top() << endl;
            }
        }
        else {
            cout << a.size() << endl;
        }
    }
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        c(n);
    }

    return 0;
}

2024/9/26 12:28
加载中...