用数组做
回复 9楼 东海一鱼
经过调试,稍改以下才是对的,大侠还是马虎了!#include <stdio.h>
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define N 4
int main()
{
int i,j;
for (i = 0; i < N; ++i, puts(""))
for ( j = 0; j < N; ++j)
{
int c = min(min(i, N-1-i), min(j, N-1-j)),
d = N-1-c, q = c*(N-c) << 2, s = 0;
if (i == c) s = q+j-c+1;
else if (j == d) s = q+d+i-c*2+1;
else if (i == d) s = q+2*d+N-j-c*3;
else if (j == c) s = q+3*d+N-i-c*4;
printf("%3d", s);
}
getch();
return 0;
}