Module Module1 '関数 Sub hanoi(n As Integer, a As Char, b As Char, c As Char) If n > 0 Then 'n-1枚の解(bとcを交換) hanoi(  @  ) '1枚の時の解 Console.WriteLine( A-1  & "→" &  A-1 ) 'n-1枚の解(aとcを交換) hanoi(  B  ) End If End Sub 'メイン Sub Main() Dim n As Integer Dim a As Char = "a" Dim b As Char = "b" Dim c As Char = "c" Dim ans As Integer Dim work As String Console.Write("何枚?:") work = Console.ReadLine() '文字で入力されるので n = Integer.Parse(work) '整数に変換する 'n枚の解(aからbに移動する) hanoi(n, a, b, c) Console.WriteLine("何かキーを押してください") Console.ReadKey() End Sub End Module