其实这道题可能完全弄懂是逻辑问题,不懂细节没关系,知道有这个方法,用的时候想到就行。但起码,写答案的时候要想到肯定用递归,并想着怎么将递归用进去。从n个盘子讲起:此时a满,b空,c空。a借c将上面的(n-1)个移到b,即move(n-1,a,c,b),a再把最大的一个盘移到c,即a-->c。此时,a空,b满(n-1),c一个最大的,只要不动它就可以把它忽略,和c柱融为一体,相当于c空。就成了一开始的样子,不过是b和a互换身份,盘子也变成(n-1)个,即move(n-1,b,a,c)。合起来就是三行:move(n-1,a,c,b) a-->c move(n-1,b,a,c)
2018-09-09
#我这样哪里不对
sum = 0
x = 1
while True:
sum=sum+x
x = x + 1
if x > 100:
break
if x%2==0:
continue
print sum
sum = 0
x = 1
while True:
sum=sum+x
x = x + 1
if x > 100:
break
if x%2==0:
continue
print sum
2018-09-09
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
2018-09-09
['<tr><td>%s</td><td>%s</td></tr>' % (name, score) for name, score in d.iteritems()]
希望这个多解释以下,%s和%没看懂
希望这个多解释以下,%s和%没看懂
2018-09-08
#input code
print 'hello world'
print 'hello','world'
print 'hello world'
print 'hello','world'
2018-09-08
s ='Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
a = 'Python was started in 1989 by "Guido".'
b = '\nPython is free and easy to learn.'
print a,b
print s
a = 'Python was started in 1989 by "Guido".'
b = '\nPython is free and easy to learn.'
print a,b
2018-09-07
#把空删掉,注意中英文
L = ['Adam',95.5,'Lisa',85,'Bart',59]
print L
L = ['Adam',95.5,'Lisa',85,'Bart',59]
print L
2018-09-06
x1 = 1
d = 3
n = 100
x100 = 1+(100-1)*3
s = 3*1+((100*(100-1))/2)*3
print s
d = 3
n = 100
x100 = 1+(100-1)*3
s = 3*1+((100*(100-1))/2)*3
print s
2018-09-06
x * 100 + y * 10 + z for x in range(0, 9) for y in range(0, 9) for z in range(0, 9) if x == z and x != 0
这样应该可以的吧
这样应该可以的吧
2018-09-06
1.首先存在错别字哈,我们成为迭代不对,是称为
2.java中也有in循环 for(int i : integers)
3.欢迎大家交流、学习
2.java中也有in循环 for(int i : integers)
3.欢迎大家交流、学习