python实现汉诺塔(递归)
def hanoi(n, A, B, C): if n > 0: hanoi(n-1, A, C, B) print("%s->%s" % (A, C)) hanoi(n-1, B, A, C) hanoi(4, 'A', 'B', 'C')
def hanoi(n, A, B, C): if n > 0: hanoi(n-1, A, C, B) print("%s->%s" % (A, C)) hanoi(n-1, B, A, C) hanoi(4, 'A', 'B', 'C')