求助!!WA2,3点
查看原帖
求助!!WA2,3点
789304
ERROR00楼主2023/3/16 15:55

求大佬教教

最后两个测试点没过,不知道为啥

#include<stack>
using namespace std;

string code;
int t,n,x;
stack <unsigned long long int> st;

int main()
{
    cin >> t;
    while(t--)
    {
        cin >> n;
        for(int i=1;i<=n;i++)
        {
            cin >> code;
            if(code=="push")
            {
                cin >> x;
                st.push(x);
            }
            else if(code=="pop")
            {
                if(st.empty()) cout << "Empty" << endl;
                else st.pop();
            }
            else if(code=="query")
            {
                if(st.empty()) cout << "Anguei!" << endl;
                else cout << st.top() << endl;
            }
            else if(code=="size") cout << st.size() << endl;
        }
    }
    return 0;
}
2023/3/16 15:55
加载中...