#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define MAXSIZE 10
int a[MAXSIZE][MAXSIZE];
int main()
{
int n,x,y,tot=0; //x,y为二维数组常用下标 ,n为输入值,tot标记值
scanf("%d",&n);
memset(a,0,sizeof(a));
tot = a[x=0][y=n-1] = 1; //连续赋值语句
while(tot < n*n) //判边界条件 !a[i]<==>a[i]==0
{
while(x+1<n && !a[x+1][y])
a[++x][y] = ++tot;
while(y-1 >= 0 && !a[x][y-1])
a[x][--y] = ++tot;
while(x - 1 >= 0 &&!a[x-1][y])
a[--x][y] = ++tot;
while(y+1 < n && !a[x][y+1])
a[x][++y] = ++tot;
}
for(x = 0;x < n;x++) //二维数组常用输出方法
{
for(x = 0;x < n;x++)
{
for(y = 0;y < n;y++)
printf("%3d",a[x][y]); //1.输出宽度默认3,2.若有“-”,表示左对齐,默认printf("%3d",a)为左对齐 3.若多于3位,则全部输出
}
printf("\n");
}
//***************************
int c=100000;
printf("%3d\n",c); //test-'%3d'
printf("%-3d\n",c);
//***************************
return 0;
}