/* 3. ´ÙÀ½ C++ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #include int _s[10]; class Stack { public: int s[10]; int top; Stack() { top = -1; init(); } void push(int x) { top++; s[top] = x; } int pop() { top--; return _s[top+1]; } void init() { for (int i = 0; i < 10; i++) _s[i] = 0; } }; void main() { Stack stack; stack.push(1); stack.push(2); stack.push(3); stack.push(4); stack.push(5); printf("%d\n",stack.pop()); printf("%d\n",stack.pop()); printf("%d\n",stack.pop()); printf("%d\n",stack.pop()); printf("%d\n",stack.pop()); }