void main (void)
{
int line = 5;
int x = 0,y = 0,ringNumber = 0,number = 0;
int A[line][line] = {0};
while (number <= line * line)
{
while (x < line - ringNumber)
{
number++;
A[x][y] = number;
x++;
}
y++;
x--;
while (y < line - ringNumber)
{
number++;
A[x][y] = number;
y++;
}
x--;
y--;
while (x >= ringNumber)
{
number++;
A[x][y] = number;
x--;
}
y--;
x++;
while (y > ringNumber)
{
number++;
A[x][y] = number;
y--;
}
x++;
y++;
ringNumber++;
}
for (int x = 0; x < line ;x++)
{
for(int y = 0 ;y < line; y++)
{
printf("%d ",A[x][y]);
}
printf("
");
}
}