/* 3. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #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]; } void init() { for (int i = 0; i < 10; i++) _s[i] = 0; } }; void main() { int array[5] = { 1, 2, 3, 4, 5 }; // ¿©±â¸¦ ¹Ù²Ü °Í Stack stack; int i; for (i = 4; i >= 0; i--) stack.push(array[i]); for (i = 0; i < 5; i++) printf("%d\n",stack.pop()); }