10032 - Stacking Blocks I
#include <iostream> #include <stack> #include <string> using namespace std; void Slove(void) { stack<string> st; string op, word; cin >> op; while (op != "quit") { if (op == "push") { cin >> word; st.push(word); } else if (op == "pop") { cout << st.top() << endl; st.pop(); } cin >> op; } } int main(void) { Slove(); return 0; }
stackが使いたかっただけです。