社区讨论
33pts HELP!!!!!!!! 求调!!!!!!
B3614【模板】栈参与者 3已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @m4p8r14k
- 此快照首次捕获于
- 2024/12/15 14:44 去年
- 此快照最后确认于
- 2025/11/04 12:48 4 个月前
CPP
#include<iostream>
#include<cstdio>
#include<stack>
#include<string>
using namespace std;
long long t,n,x;
string s1;
stack<unsigned long long int> s;
int main()
{
cin>>t;
for(int i=1;i<=t;i++)
{
cin>>n;
for(int j=1;j<=n;j++)
{
cin>>s1;
if(s1=="push")
{
cin>>x;
s.push(x);
}
if(s1=="pop")
{
if(!s.empty()) s.pop();
else cout<<"Empty"<<endl;
}
if(s1=="query")
{
if(!s.empty()) cout<<s.top()<<endl;
else cout<<"Anguei!"<<endl;
}
if(s1=="size") cout<<s.size()<<endl;
}
}
while(!s.empty()) s.pop();
return 0;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...