We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a2b6111 commit 5831353Copy full SHA for 5831353
1 file changed
260318/정수 명령 처리 2/process-numeric-commands-2.cpp
@@ -0,0 +1,40 @@
1
+#include <iostream>
2
+#include <queue>
3
+#include <string>
4
+using namespace std;
5
+
6
+int main() {
7
+ string input;
8
+ queue<int> My_q;
9
+ int loop_num;
10
+ cin >> loop_num;
11
12
+ for (int i = 0; i < loop_num; i++) {
13
+ cin >> input;
14
15
+ if (input == "push") {
16
+ int num;
17
+ cin >> num;
18
+ My_q.push(num);
19
+ } else if (input == "pop") {
20
+ if (My_q.empty()) {
21
+ break;
22
+ } else {
23
+ cout << My_q.front() << '\n';
24
+ My_q.pop();
25
+ }
26
+ } else if (input == "size") {
27
+ cout << My_q.size() << '\n';
28
+ } else if (input == "empty") {
29
+ if (My_q.empty())
30
+ cout << 1 << '\n';
31
+ else
32
+ cout << 0 << '\n';
33
+ } else if (input == "front") {
34
35
36
37
38
39
+ return 0;
40
+}
0 commit comments