10033 - Stacking Blocks II
#include <iostream> #include <stack> #include <string> using namespace std; void Slove(int n) { stack<string> st[n]; int p, p1, p2; string op, c; cin >> op; while (op != "quit") { if (op == "push") { cin >> p >> c; st[p-1].push(c); } else if (op == "pop") { cin >> p; cout << st[p-1].top() << endl; st[p-1].pop(); } else if (op == "move") { cin >> p1 >> p2; st[p2-1].push( st[p1-1].top() ); st[p1-1].pop(); } cin >> op; } } int main(void) { int n; cin >> n; Slove(n); return 0; }
やるだけ。。