STL栈【模板】代码求调
查看原帖
STL栈【模板】代码求调
516867
SZnP楼主2022/7/24 20:44
#include <bits/stdc++.h>
using namespace std;
typedef int Int;
stack<int> a;
int T,n,pu;
char k[20];
void Input()
{
    scanf("%d",&T);
    for(int ti=0;ti<T;ti++)
    {
        scanf("%lld",&n);
        for(Int i=0;i<n;i++)
        {
            scanf("%s",k);
            if(k[0]=='p'&&k[1]=='u'){cin>>pu;a.push(pu);}else
            if(k[0]=='p'&&k[1]=='o'){if(a.empty())cout<<"Empty\n";else a.pop();}else
            if(k[0]=='q'&&k[1]=='u'){if(a.empty())cout<<"Anguei!\n";else cout<<a.top()<<endl;}else
            if(k[0]=='s'&&k[1]=='i'){cout<<a.size()<<endl;}
        }
        while(!a.empty())a.pop();
    }
    return;
}
int main()
{
    Input();
    return 0;
}
2022/7/24 20:44
加载中...