有个想法
Topic source# -- coding: utf-8 -- #定义一个全局变量步数 step=1;
def move(n, a, b, c): #使用全局变量step global step if n == 1: print(step,':',a, '-->', c) step=step+1 else: move(n-1,a,c,b) print(step,':',a, '-->', c) step=step+1 move(n-1,b,a,c) move(3, 'A', 'B', 'C')
- 1
用户5214616314
要在每一步前显示这是第几次移动(序号)的话该怎么写呢...