社区讨论
求助求助求助求助求助求助求助求助求助求助求助超求助
B3614【模板】栈参与者 3已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @mhjd656s
- 此快照首次捕获于
- 2025/11/04 00:38 4 个月前
- 此快照最后确认于
- 2025/11/04 00:38 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
int a[1000000]={};
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
for(int xhy=1;xhy<=t;xhy++){
for(int i=1;i<=1000000;i++){
a[i]=-999999999;
}
int n,temp=0,o;
cin>>n;
string p;
for(int i=1;i<=n;i++){
cin>>p;
if(p=="push"){
cin>>o;
temp++;
a[temp]=o;
}
if(p=="pop"){
if(a[1]==-999999999){
cout<<"Empty"<<endl;
}else{
a[temp]=-999999999;
}
}
if(p=="query"){
if(a[1]==-999999999){
cout<<"Anguei!"<<endl;
}else{
cout<<a[temp]<<endl;
}
}
if(p=="size"){
if(a[1]==-999999999){
cout<<0<<endl;
}else{
cout<<temp<<endl;
}
}
}
}
return 0;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...