mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:08:47 +00:00
829. 模拟队列
https://www.acwing.com/problem/content/submission/code_detail/7414626/
This commit is contained in:
parent
01ab18dd50
commit
1ef3672428
25
AcWing/829/829.cpp
Normal file
25
AcWing/829/829.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int m, x;
|
||||
string op;
|
||||
queue<int> q;
|
||||
|
||||
int main() {
|
||||
cin >> m;
|
||||
while (m--) {
|
||||
cin >> op;
|
||||
if (op == "push") {
|
||||
cin >> x;
|
||||
q.push(x);
|
||||
} else if (op == "pop") {
|
||||
q.pop();
|
||||
} else if (op == "empty") {
|
||||
cout << (q.empty() ? "YES" : "NO") << endl;
|
||||
} else {
|
||||
cout << q.front() << endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user