注意:
(1)用min函数时记得加头文件
(2)本题是取某一位置到四边的最短距离
(3)注意格式
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int main()
{
int n;
scanf(“%d”,&n);
while(n!=0)
{
int i,j,a;
for(i=0;i<n;i)
{
for(j=0;j<n;j)
{
int up=i+1,down=n-i,left=j+1,right=n-j;
a=min(min(up,down),min(left,right));
printf(“%d “,a);
}
printf(“\n”);
}
printf(“\n”);
scanf(“%d”,&n);
}
return 0;
}