Home > Back-end >  Please bosses help to see if the problem is?
Please bosses help to see if the problem is?

Time:10-28


#include
#include
Int main ()
{
Int m, n, k, I, j, n.
Int * p=NULL;
The scanf (" % d ", & amp; N);
P=(int *) calloc (N * N, sizeof (int));
P [0 * N + (N - 1)/2]=1;
P/N + (N - 1) * (N + 1)/2]=2;
For (k=3; k<=N * N; K++)
{
for(i=0; i<=N - 1; If i++)/* (K? 1) in the first line but not in the last column, fill in the last line will be K, (K - 1) in the column of the right column */
{
If (p * N + I] [0==k - 1 & amp; & i!=N - 1)
[p (N - 1) * N + I + 1]=k;
}
If (p [(N - 1) * N + I + 1)==k)
{
M=N - 1;
N=I + 1;
continue;
}
for(i=0; i<=N - 1; If i++)/* (K - 1) in the last column but not in the first row, will fill in the first column, K (K - 1) on the same line of */
{
If (p [I] * N + N - 1==k - 1 & amp; & i!=0)
{
[p (I - 1) * N + 0]=k;
M=I - 1;
N=0;
continue;
}
}
If (p [0] * N + N - 1==k - 1)/* (k - 1) if the last column in the first row, will fill in k (k - 1) */just below
{
P (1 * N + N - 1]=k;
m=1;
K=N - 1;
continue;
}
/* (K - 1) if neither in the first row, is not in the last column, if the top right (K - 1) also incompletely,
Will fill in K (K - 1) of the upper right, otherwise will fill in K (K - 1) below, */
for(i=0; i<=N - 1; I++)
{
If (p [0 * N + I]!=k - 1 & amp; & P [I * N + N - 1)!=k - 1 & amp; & [p (m - 1) * N + k + 1)==0)
[p (m - 1) * N + k + 1]=k;
The else p/N + (m + 1) * k]=k;
}
}
for(i=0; i<=N - 1; I++)
{
for(j=0; j<=N - 1; J++)
Printf (" % d ", p/I * N + j).
printf("\n");
}
free(p);
return 0;
}
  • Related