1 条题解

  • 0
    @ 2026-5-17 15:12:46

    上代码!

    /***************************
    NUM:
    ***************************/
    #include <bits/stdc++.h>
    using namespace std;
    const int SB=1e6+10;
    int s[SB],tot,n;
    void push(int x){
        s[++tot]=x;
    }
    void pop(){
        tot--;
    }
    int top(){
        return s[tot];
    }
    int main ()
    {
        system("color 2");
        cin>>n;
        for(int i=1;i<=n;i++){
            int op,x;
            cin>>op;
            if(op==1){
                cin>>x;
                push(x);
            }else if(op==2){
                pop();
            }else if(op==3){
                cout<<top()<<endl;
            }
        }
        return 0;
    }
    
    • 1

    信息

    ID
    3551
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    (无)
    递交数
    38
    已通过
    16
    上传者