From 03630f4f075bab21652f524e8cead218de9fbb00 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 3 Aug 2021 21:22:28 +0800 Subject: [PATCH] =?UTF-8?q?828.=20=E6=A8=A1=E6=8B=9F=E6=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/6873731/ --- AcWing/828/828.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 AcWing/828/828.cpp diff --git a/AcWing/828/828.cpp b/AcWing/828/828.cpp new file mode 100644 index 00000000..b478b990 --- /dev/null +++ b/AcWing/828/828.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() { + int m; + cin >> m; + stack q; + while (m--) { + string op; + cin >> op; + if (op == "push") { + int x; + cin >> x; + q.push(x); + } + if (op == "pop") q.pop(); + if (op == "empty") cout << (q.empty() ? "YES" : "NO") << endl; + if (op == "query") cout << q.top() << endl; + } + return 0; +}