[求助]魔方阵问题~请各位指点一下呀~
一道魔方阵的程序:#include <stdio.h>
#define NUM 6
main()
{
int magic[NUM][NUM]={0};
int i,j,value;
i=0;j=NUM/2;
magic[i][j]=1;
for(value=2;value<=NUM*NUM;value++)
{ if(magic[(i-1+NUM)%NUM][(j+1)%NUM]==0) //请帮忙说一下这句是怎么想出来的~
{ i=(i-1+NUM)%NUM;
j=(j+1)%NUM;}
else{
i=(i+1)%NUM;}
magic[i][j]=value;}
printf("\nThe magic(%d*%d) is:\n",NUM,NUM);
for(i=0;i<NUM;i++)
{ for(j=0;j<NUM;j++)
printf("%4d",magic[i][j]);
printf("\n");}
}