def hnoi(n,a,b,c):
if n == 1:
print a,c
else:
hnoi(n-1,a,c,b)
print a,c
hnoi(n-1,b,a,c)
hnoi(3,‘a‘,‘b‘,‘c‘)
时间: 2024-10-14 18:37:30
def hnoi(n,a,b,c):
if n == 1:
print a,c
else:
hnoi(n-1,a,c,b)
print a,c
hnoi(n-1,b,a,c)
hnoi(3,‘a‘,‘b‘,‘c‘)