Skip to content

Commit 5831353

Browse files
committed
Title: 정수 명령 처리 2, Time: 22ms, Memory: 0MB, Status: Passed - Codetree
1 parent a2b6111 commit 5831353

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
cout << My_q.front() << '\n';
35+
}
36+
37+
}
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)