#include <stdio.h>
#define BUFSIZE 100
#define DOWN 0
#define LEFT 1
#define UP 2
#define RIGHT 3

int main(void){
    int i, j, k = 0;
    int direction = DOWN;
    int index = 0;
    int n = 0;
    int numbers[BUFSIZE] = {0,};
    int ret[BUFSIZE][BUFSIZE] = {
        {0, },
        {0, }
    };
    printf("n : ");
    scanf("%d", &n);

    for(i=0; i<n*n; i++){
        numbers[i] = i+1;
    }

    // 첫 줄은 수동완성이긔
    ret[0][0] = numbers[index++];
    for(i=0; i<(n-1); i++){
        ret[0][i+1] = numbers[index++];
    }

    for(i=0; i<(n-1); i++){
        for(j=0; j<2; j++){
            for(k=0; k<n-1-i; k++){
                if(direction == DOWN){
                    ret[k+1+(i/2)][n-1-(i/2)] = numbers[index++];
                } else if(direction == LEFT){
                    ret[n-1-(i/2)][n-2-k-(i/2)] = numbers[index++];
                } else if(direction == UP){
                    ret[n-2-k-(i/2)][i-1-(i/2)] = numbers[index++];
                } else if(direction == RIGHT){
                    ret[i-(i/2)][k+1+(i/2)] = numbers[index++];
                }
            }
            if(direction==3){
                direction=0;
            } else{
                direction++;
            }
        }
    }
    // 출력
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            printf("%3d ", ret[i][j]);
        }
        printf("n");
    }

    return 0;
}


저는요... 달팽이 문양을 한점액.... 한점액씩..... 전진하는 달팽이를 떠올리며 짰어요.

특정 칸에 무엇이.... 들어가야.... 하는지는.....

 지금이 몇 바퀴째인지.....

 제가 달팽이 모양에서 뽑아낸 패턴 중에....

지금이 어느 패턴인지를 통해 알아내요...

달팽이.... 짱짱... 재밋는거... 가타여....

담에는... 간 길 다시 돌아나오는 달팽이를....

만들어 바야 겟서요......