Discuss / Python / 交作业附个人思考过程

### 交作业附个人思考过程

Topic source

#### 腿腿小魔王

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

``````if n==1:
print(a,'-->',c)
return
``````

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

``````move(1,a,b,c)
``````

``````move（n-1,b,a,c）
``````

``````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)
``````

#### 旅行的Martin

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

#### 清纯大叔感动天

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

#### 清纯大叔感动天

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

``````在此插入代码
``````

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)

#### 张文祥_stone

#5 Created at ... [Delete] [Delete and Lock User]
``````if n == 1:
print(a,'-->',c)
else:
move(n-1,a,c,b)#借助c将a上的n-1移到b盘
print(a,'-->',c)#将a盘的最大一个(最后一个)移到c盘
move(n-1,b,a,c)#然后借助a盘将b盘的n-1全部移到c盘
#至此，汉诺塔移动完成
``````

#### 深海长流往

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

#### 追波逐浪的围脖

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

else:

#### 单车少年永远17岁

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

• 1