這題偷懶,直接用內建函示庫

 

#include<iostream>
#include<stack>


using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

 

 

    stack<int> num;

    int n, op, element;
    while(cin >> n)
    {
        while(n--)
        {
            cin >> op;

            switch(op)
            {
                case 1:
                    num.pop(); break;
                case 2:
                    cout << num.top() << endl; break;
                case 3:
                    cin >> element;
                    num.push(element);
                    break;
                default: break;
            }
        }
    }

}

 
arrow
arrow
    全站熱搜

    大神(偽) 發表在 痞客邦 留言(0) 人氣()