#include <stdio.h>
int main() {
int buf[5][5] = {0};
int Limitof_x = 0;
int Limitof_y = 0;
int i, j, num;
i=j=0;
num = 1;
while(1)
{
for (i = Limitof_x; i < (5 - Limitof_x); i++)
buf[i][j] = num++;
i--;
for (j = Limitof_y; j < (5 - Limitof_y); j++)
buf[i][j] = num++;
j--;
for (i = (5 - Limitof_x -2); i >= Limitof_x; i--)
buf[i][j] = num++;
i = Limitof_x;
for (j = (5 - Limitof_y -2); j > Limitof_y; j--)
buf[i][j] = num++;
Limitof_x++;
Limitof_y++;
i = Limitof_x;
j = Limitof_y;
if( j == 2 )
{
buf[i][j] = num;
break;
}
}
for ( i = 0; i < 5; i++ )
{
for ( j = 0; j < 5; j++)
printf("%3d\t",buf[i][j]);
printf("\n");
}
return 0;
}
저딴식으로
행값이 마지막에 점프합니다... 계속 생각중이고 테스트해봐도 모르겠습니다.
5는 어디갔어
예전에 누가 막 하던데 달팽이 라고 검색하면 나올듯
아 해결했습니다. ㅋㅋ