Discuss / Python / 递归函数 打卡

递归函数 打卡

Topic source

某猪头四

#1 Created at ... [Delete] [Delete and Lock User]

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

        if n == 1:

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

            # 将最大盘,从A柱移动到C柱

        else:

            # 将第n-1个盘,借助C柱,从A柱移动到B柱

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

            # 将最大盘,从A柱移动到C柱

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

            # 将n-1个圆,借助A柱,从B柱移动到C柱

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

move(64, 'A', 'B', 'C')

红特小将

#2 Created at ... [Delete] [Delete and Lock User]

为什么开始abc是小写,后来就成了大写呢?


  • 1

Reply