Why did I WA?!
查看原帖
Why did I WA?!
594203
BartonMeow楼主2022/3/14 21:29
#include <iostream>
#include <stack>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    stack<unsigned long long> mys;
    unsigned long long n, m, a;
    string opr;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> m;
        for (int j = 0; j < m; j++)
        {
            cin >> opr;
            if (opr == "push")
            {
                cin >> a;
                mys.push(a);
            }
            else if (opr == "pop")
            {
                if (mys.empty())
                    cout << "Empty" << endl;
                else mys.pop();
            }
            else if (opr == "query")
            {
                if (mys.empty())
                    cout << "Anguei!" << endl;
                else cout << mys.top() << endl;
            }
            else cout << mys.size() << endl;
        }
    }
    return 0;
}

2022/3/14 21:29
加载中...