Quote:
引用第8楼donney于2006-11-10 23:12发表的:
算法?
任意奇数阶幻方的C++实现
#include <iostream.h>
void main()
{
int n;
cin>>n;
for (int j = 1; j <= n; j++)
{
for (int i = 1; i <= n; i++)
{
cout<<((i + j + (n - 3) / 2) % n) * n + (i - j + (3 * n - 1) / 2) % n + 1<<"\t";
}
cout<<endl;
}
}
n是待输入得奇数阶