2 solutions

  • 0
    @ 2026-9-13 11:13:45

    #include<bits/stdc++.h> using namespace std; int a[6],top; void push(int x){ if(top<5){ top++; a[top]=x; } return; } void pop(){ if(top>0){ top--; } return; } int getTop(){ return a[top]; } void clear(){ top=0; return; }

    int main(){ for(int i=1;i<=5;i++){ int t; cin>>t; push(t); } for(int i=0;i<3;i++){ cout<<getTop()<<' '; pop(); } cout<<endl<<getTop(); return 0; }

    Information

    ID
    2320
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    25
    Accepted
    8
    Uploaded By