/* 2. 다음 프로그램의 출력을 써라. */

#include <stdio.h>

class Stack {
	int x;
	int y[10];
public:
	Stack() {
		x = 0;
		for (int i = 0; i < 10; i++) 
			y[i] = 0;
	}
	void push(int a) {
		int &z = x;
		y[0] = a;
		z++;
		y[z] = z;
	}
	void pop() {
		if (x > 0) x--;
	}
	void print() {
		for (int i = 0; i < 10; i++) 
			printf("%d\n",y[i]);
	}
};

void main() 
{
	Stack x;
	int y[5] = { 1, 2, 3, 4, 5 }; // 여기를 바꿀 것

	for (int i = 0; i < 5; i++) {
		x.push(y[i]); 
	}
	for (i = 0; i < 5; i++) {
		x.pop();
	}
	x.print();
}