代码如下:
times = 0
def test(num,a,b,c):
globaltimes
ifnum==1:
print (a,b)
times+=1
else:
test(num-1,a,c,b)
test(1,a,b,c)
test(num-1,c,b,a)
test(12,"a","b","c")
print "经过的步数passing:%d"%times
查看更多关于python益智游戏计算汉诺塔问题示例的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did90382