样例过但全WA QAQ

B3614 【模板】栈

vector_STL_ @ 2024-10-11 22:55:44

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    stack<int>f;
    int a;
    cin>>a;
    for(int i=0;i<a;i++){
        int b;
        cin>>b;
        for(int j=0;j<b;j++){
            string s;
            cin>>s;
            if(s=="push"){
                int c;
                cin>>c;
                f.push(c);
            }
            if(s=="pop"){
                if(f.size()==0){
                    cout<<"empty"<<endl;
                }
                else{
                    f.pop();
                }
            }
            if(s=="query"){
                if(f.size()==0){
                    cout<<"Anguei!"<<endl;
                }
                else{
                    int c=f.top();
                    cout<<c<<endl;
                }
            }
            if(s=="size"){
                cout<<f.size()<<endl;
            }
        }
    }
}

by zts201210 @ 2024-10-11 23:01:35

@zch120526

            if(s=="pop"){
                if(f.size()==0){
                    cout<<"empty"<<endl;
                }
                else{
                    f.pop();
                }
            }

Empty 首字母大写


|