我在网上找的
#include <stdio.h>
#include <conio.h>
main()
{ int a[19][19],i,j,k,m,n,p;
do
{
printf("The program of print a 19*19 bewitching phalanx\r\n");
printf("Enter n (n is a odd number from 1 to 19):> ");
scanf("%d",&n);
}while((n!=0)&&(n<=19)&&(n%2==1)==0);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
a[j][i]=0;
}
j=n/2;
a[0][j]=1;
for(k=2;k<=n*n;k++)
{ i=i-1;
j=j+1;
if((i<0)&&(j>n-1))
{ i=i+2;
j=j-1;
}
else
{ if(i<0)
i=n-1;
if(j>n-1)
j=0;
}
if(a[j][i]==0)
{
a[j][i]=k;
}
else
{ i=i+2;
j=j-1;
a[j][i]=k;
}
}
printf("\n");
for(i=0;i<n;i++)
{ for(j=0;j<n;j++)
printf("%4d",a[j][i]);
printf("\n");
}
printf("\r\nThank you to use the program ! Pass any key to exit ...");
getch();
}