From c0794da40e73948ce6655f3eb04596fbc780d263 Mon Sep 17 00:00:00 2001 From: EunJin Lee <50702052+witheunjin@users.noreply.github.com> Date: Tue, 3 Mar 2020 22:17:57 +0900 Subject: [PATCH] =?UTF-8?q?Create=2010845=5F=ED=81=90.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "BaekJoon/10845_\355\201\220.cpp" | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "BaekJoon/10845_\355\201\220.cpp" diff --git "a/BaekJoon/10845_\355\201\220.cpp" "b/BaekJoon/10845_\355\201\220.cpp" new file mode 100644 index 0000000..a6057f4 --- /dev/null +++ "b/BaekJoon/10845_\355\201\220.cpp" @@ -0,0 +1,41 @@ +#include +#include +using namespace std; + +queue q; +void match(string para) { + if (para == "push") { + int x; + cin >> x; + q.push(x); + } + else if (para == "pop") { + if (q.empty()) cout << -1 << endl; + else { cout << q.front() << endl; q.pop(); } + } + else if (para == "size") { + cout << q.size() << endl; + } + else if (para == "empty") { + if (q.empty()) cout << 1 << endl; + else cout << 0 << endl; + } + else if (para == "front") { + if (q.empty()) cout << -1 << endl; + else cout << q.front() << endl; + } + else if (para == "back") { + if (q.empty()) cout << -1 << endl; + else cout << q.back() << endl; + } +} +int main() { + int N; + cin >> N; + string command; + for (int i = 0; i < N; ++i) { + cin >> command; + match(command); + } + return 0; +} \ No newline at end of file