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')

 

相关文章:

  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-12-25
  • 2021-04-26
  • 2021-08-30
猜你喜欢
  • 2021-10-08
  • 2022-12-23
  • 2022-01-11
  • 2021-11-02
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案