Discuss / Python / 交作业

交作业

Topic source
def move(n, a, b, c):

if n == 1:

        print(a, '-->', c)

    else:

        move(n-1, a, c, b)

        move(1, a, b, c)

        move(n-1, b, a, c)

运用递归的思想,有n=1的结果,那么我们考虑n=n-1+1,拆分步骤即可


  • 1

Reply