#include<stdio.h>
int main(void)
{
int n,i,j;
scanf("%d",&n);
int a[10][10],index,num,m=1;
num=n;
for(index=0; index<=n-1; index++)
{
for(j=index; j<n; j++)
{
a[index][j]=m;
m++;
}
for(i=index; i<n-1; i++)
{
a[i+1][n-1]=m;
m++;
}
for(j=n-1; j>index; j--)
{
a[n-1][j-1]=m;
m++;
}
for(i=n-1; i>1+index; i--)
{
a[i-1][index]=m;
m++;
}
n=n-1;
}
for(i=0; i<num; i++)
{
for(j=0; j<num; j++)
{
printf("%4d",a[i][j]);
}
printf("\n");
}
return 0;
}
05-26
369
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-24
4652
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-07
3758
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-11
04-07