[Perl] hanoi
sub hanoi {my ($mai , $x, $y, $z) =@_;if ($mai > 0){hanoi($mai-1 , $x , $z , $y );print "move", $mai ,"from", $x ,"to", $z ,"\n";hanoi($mai-1 , $y , $x , $z );}}hanoi(3, "A", "B", "C"); 상기의 결과에 더해, 각행의 선두에 수순의 순번수를 출력하도록 변경해라. use strict;use warnings; my $i = 0; sub hanoi {my ($mai , $x, $y, $z) =@_;if ($mai > 0){hanoi($mai-1 , $x , $z , $y );print ++$i;print "move", $mai ,"from", $x ,"to", $z ,..
더보기