今日からプログラム勉強するぞ 3
■ このスレッドは過去ログ倉庫に格納されています
0065デフォルトの名無しさん
NGNGimplicit none
integer :: i
read *, i
if (i>0) call solve(i, 1, 3, 2)
contains
recursive subroutine solve(n, from, to, tmp)
integer, intent(in) :: n, from, to, tmp
if (n>0) then
call solve(n-1, from, tmp, to)
print *, "Move disk #", n, " from", from, " to", to
call solve(n-1, tmp, to, from)
end if
end subroutine solve
end program hanoi
■ このスレッドは過去ログ倉庫に格納されています