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

#include <stdio.h>

int number[5] = { 1, 2, 3, 4, 5 }; // 여기를 바꿀 것

class Ex {
	int _x;
public:
	Ex(int x) { _x = x; }
	int getX() { return _x; }
};

class Test {
	int *s;
	int i;
public:
	Test(int x[]) { s = x; i = 0; }
	void foo() {
		int mod = i % 4;
		i++;
		if (mod == 0) {
			throw s[i-1];
		} else if (mod == 1) {
			throw new Ex(s[i-1]);
		} else if (mod == 2) {
			printf("Here !\n");
		} else {
			throw "Shit !";
		}
	}
};

void main()
{
	Test data(number);

	for(int i = 0; i < 5; i++) {
		try {
			printf("Hello !\n");
			data.foo();
			printf("World !\n");
		} catch(int ex) {
			printf("%d\n",ex);
		} catch(char *ex) {
			printf("%s\n",ex);
			break; // 루트 탈출하기
		} catch(Ex *ex) {
			printf("%d\n",ex->getX());
		}
	}
}