奇阶幻方

奇阶幻方

奇阶幻方
[code]
##### Name: xnnyy.pl
##### Version: 0.0.0.1
##### Author: y6cmE
##### Updated: 2003-9-21
$|=1;
open(F,">xnnyy.txt");
my $x=7;
my $y=int($x/2);
my @z=(()x$x);
my($e,$v,$n,$m);
for(1..$x*$x){
if($_ > $x){
$n=(--$n+$x)%$x;
$m=(1+$m++)%$x;
if($z[$n][$m]){
$n=($n+2)%$x;
$m=($m-1)%$x;
$z[$n][$m]=$_;
print F "$_\t$n\t$m\n";
}
else{
$n=$n;
$m=$m;
$z[$n][$m]=$_;
print F "$_\t$n\t$m\n";
}
}
else{
$n=($x+$e--)%$x;
$m=(++$v+$y-1)%$x;
$z[$n][$m]=$_;
print F "$_\t$n\t$m\n";
}
}
close F;
### Enjoy
[/code]
好复杂.