Discuss / Python / 作业

作业

Topic source

def hannuo(n,x,y,z):

    if n==1:

        print("移动路径:",x,"--->",z)

    else:

        hannuo(n-1,x,z,y)

        print(x,"---->",z)

        hannuo(n-1,y,x,z)

n=int(input("请输入层数"))

hannuo(n,"a","b","c")


  • 1

Reply