/***********************************************************
hanoi.c -- ハノイの塔
***********************************************************/
#N88BASIC

Sub movedisk(n As Long, a As Long, b As Long)
If (n > 1) Then movedisk(n - 1, a, 6 - a - b)
Print "円盤 ";n;" を ";a;" から ";b;" に移す"
If (n > 1) Then movedisk(n - 1, 6 - a - b, b)
End Sub

Sub main()
Dim n As Long

Input "円盤の枚数? ";n
Print "円盤 ";n;" 枚を柱 1 から柱 2 に移す方法は 次の ";(1 << n) -1;" 手です"
movedisk(n, 1, 2)

End Sub

main()