~c
#include <stdio.h>
#include <stdlib.h>
#define	NORTH 1
#define	NORTH_WEST 2
#define	SOUTH_WEST 3
#define	SOUTH 4
#define	SOUTH_EAST 5
#define CAL(x) ((3*x*x)+(3*x)+1)
struct coordinate{
	int x;
	int y;
} posi;
void move_posi(struct coordinate *, int);
int main(void)
{
	int willy, row, seq, i;
	
	printf("윌리의 좌표계를 입력하세요 : ");
	while(scanf("%d", &willy)){
		if(!willy) exit(0);
		posi.x = 0; posi.y = 0;
		for (row=0; CAL(row) < willy; row++) move_posi(&posi, SOUTH_EAST);
	
		willy -= CAL(row);
		for(seq=NORTH; willy; seq++)
			for(i=0; i < row && willy; i++, willy++) move_posi(&posi, seq);
	
		if(willy == 0)
		printf("(%d, %d)\n\n", posi.x, posi.y);
		printf("윌리의 좌표계를 입력하세요 : ");
	}
	return 0;	
}
void move_posi(struct coordinate *posi, int direc)
{
	switch(direc)
	{
	case NORTH:
		posi->y--;
		break;
	case NORTH_WEST:
		posi->x--;
		break;
	case SOUTH_WEST:
		posi->x--;
		posi->y++;
		break;
	case SOUTH:
		posi->y++;
		break;
	case SOUTH_EAST:
		posi->x++;
		break;
	default:
		puts("정상적인 작동이 아니므로 종료합니다.");
		exit(1);
	}
}