Home > Back-end >  Why did this magic square program it? Even though? Wrong, refer new PI _ PI
Why did this magic square program it? Even though? Wrong, refer new PI _ PI

Time:12-18

# include
# include

Int main ()
{
Int a [39] [39]={0}, I, j, n, k, c, b;
k=0;
scanf("%d",&n);

for(i=0; ifor(j=0; j{

K++;
If (k==1)
A [0] [(n - 1)/2]=k;


The else
{
for(i=0; ifor(j=0; jIf (a [I] [j]==k - 1)
{
C=I;
B=j;
}

If (==0 c & b!=n - 1)
[b] a [n - 1 + 1]=k;
Else if (c!=0 && b==n - 1)
A/c - 1] [0]=k;
Else if (==0 c & b==n - 1)
A [b] [c + 1]=k;
The else
{
If (a/c - 1 [b + 1)==0)
[b] a [c - 1 + 1]=k;
The else
A [b] [c + 1]=k;
}
}
}

for(i=0; ifor(j=0; j{
If (j!=n - 1)
Printf (" % d ", a [I] [j]);
The else
Printf (" % d \ n ", a [I]], [n - 1);
}

return 0;
}
  • Related