ぴょん #3607(2007/10/30 19:16 GMT) [ Perl ] Rating-1/1=-1.00
Perl がなかったので。力技。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use strict; my $PI = atan2(1, 1) * 4; my $MAXR = int(sqrt(1000 / $PI) + sqrt(2) + 0.5); my @res = (); for (my $i = 0; $i <= $MAXR; $i++) { for (my $j = 0; $j <= $MAXR; $j++) { my $r = sqrt($i * $i + $j * $j); push(@res, [$i, $j, $r, atan2($j, $i)]); ($i != 0) && push(@res, [-$i, $j, $r, atan2($j, -$i)]); ($j != 0) && push(@res, [$i, -$j, $r, atan2(-$j, $i) + 2 * $PI]); ($i * $j != 0) && push(@res, [-$i, -$j, $r, atan2(-$j, -$i) + 2 * $PI]); } } foreach my $p (sort {($a->[2] <=> $b->[2]) || ($a->[3] <=> $b->[3])} @res) { printf("%3d, %3d\n", splice(@{$p}, 0, 2)); }
Rating-1/1=-1.00-0+
[ reply ]
ぴょん #3607() [ Perl ] Rating-1/1=-1.00
Rating-1/1=-1.00-0+