已采纳回答 / rookie2geek
如果a只有一个圆盘,可以直接移动到c;如果a有N个圆盘,可以看成a有1个圆盘(底盘) + (N-1)个圆盘,首先需要把 (N-1) 个圆盘移动到 b,然后,将 a的最后一个圆盘移动到c,再将b的(N-1)个圆盘移动到c。请编写一个函数,给定输入 n, a, b, c,打印出移动的步骤:move(n, a, b, c)例如,输入 move(2, 'A', 'B', 'C'),打印出:A --> BA --> CB --> C首先搞明白这个函数 表明的目标是 n 个盘子 从a 到c 其中可以...
2016-07-23
已采纳回答 / 好吧123
这句相当于move(1,a,b,c) 因为当n==1 print a,'-->',c 后面的abc调换顺序只是相当于目标柱发生改变。例如move(2,a,c,b)的含义就是把2个从a移到b
2016-07-23
def square_of_sum(L):
i=[]
for x in L:
i.append(x**2)
S = sum(i)
return S
我是真的没懂评论区得for是怎么用的啊
i=[]
for x in L:
i.append(x**2)
S = sum(i)
return S
我是真的没懂评论区得for是怎么用的啊
2016-07-22
def square_of_sum(L):
s = []
for x in L:
s.append(x * x)
return sum(s)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
s = []
for x in L:
s.append(x * x)
return sum(s)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2016-07-22
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'
自行取用
自行取用
2016-07-22
1. L.pop(3) 2.L.pop(2) 3. L.pop() 4.L.pop(2)
L.pop(2) L.pop(2) L.pop(2) L.pop()
L.pop(2) L.pop(2) L.pop(2) L.pop()
2016-07-22
//L = [95.5, 85, 59]
//print L[-1]
//print L[-2]
//print L[-3]
//print L[-4]
神了,这样也能通过
//print L[-1]
//print L[-2]
//print L[-3]
//print L[-4]
神了,这样也能通过
2016-07-22
sum = 0
x = 1
n = 1
while True:
x=2**(n-1)
n+=1
sum+=x
if n>20:
break
print sum
x = 1
n = 1
while True:
x=2**(n-1)
n+=1
sum+=x
if n>20:
break
print sum
2016-07-22