社区讨论
编译top函数没过。。。求调
B3614【模板】栈参与者 4已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lr6g96dd
- 此快照首次捕获于
- 2024/01/09 22:31 2 年前
- 此快照最后确认于
- 2024/01/10 14:08 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
int t, n, x;
string s;
int main(){
cin >> t;
for(int i=0; i<t; i++){
cin >> n;
queue<unsigned long long> q;
for(int i=0; i<n; i++){
cin >> s;
if(s=="push"){
cin >> x;
q.push(x);
}
else if(s=="pop"){
if(q.empty()) cout << "Empty";
else q.pop();
}
else if(s=="query"){
if(q.empty()) cout << "Anguei!";
else cout << q.top();
}
else{
cout << q.size();
}
}
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...