為什么我這種是錯的呢?
?def move(n, a, b, c): ? ?if n == 1: ? ? ? ?print(a,'-->',c) ? ? ? ?return ? ?move(n-1,a,c,b) ? ?print(1,a,b,c) ? ?move(n-1,b,a,c) ? ?n =int(input('請輸入圓盤數:')) move(4, 'A', 'B', 'C')
?def move(n, a, b, c): ? ?if n == 1: ? ? ? ?print(a,'-->',c) ? ? ? ?return ? ?move(n-1,a,c,b) ? ?print(1,a,b,c) ? ?move(n-1,b,a,c) ? ?n =int(input('請輸入圓盤數:')) move(4, 'A', 'B', 'C')
2016-03-14
舉報
2016-03-15
不行,我嘗試了。
2016-03-14
?n =int(input('請輸入圓盤數:'))去掉這句代碼就好了,int應該是直接跟參數吧