标签:color code int python 递归 format pytho one div style
# 汉诺塔 a = "A" b = "B" c = "C" def hano(a, b, c, n): if n == 1: print("{} --> {}".format(a, c)) if n == 2: print("{} --> {}".format(a, c)) print("{} --> {}".format(a, b)) print("{} --> {}".format(b, c)) return None hano(a, b, c, n - 1) print("{} --> {}".format(a, c)) hano(b, a, c, n - 1) hano(a, b, c, 5)
A --> C A --> B B --> C A --> C B --> C B --> A A --> C A --> C B --> C B --> A A --> C B --> C A --> C A --> B B --> C A --> C B --> C B --> A A --> C B --> C A --> C A --> B B --> C B --> C A --> C A --> B B --> C A --> C B --> C B --> A A --> C
标签:color code int python 递归 format pytho one div style
原文地址:https://www.cnblogs.com/vvrr/p/11306339.html