global i
i=0
def pt(n,a,c):
global i
i=i+1
print i,'Step:','Take',n,'from',a,'to',c
def move(n, a, b, c):
if n==1:
pt(n,a,c)
else:
move(n-1,a,c,b)
pt(n,a,c)
move(n-1,b,a,c)
move(4,'a', 'b', 'c')
这个是加上步数
i=0
def pt(n,a,c):
global i
i=i+1
print i,'Step:','Take',n,'from',a,'to',c
def move(n, a, b, c):
if n==1:
pt(n,a,c)
else:
move(n-1,a,c,b)
pt(n,a,c)
move(n-1,b,a,c)
move(4,'a', 'b', 'c')
这个是加上步数
2015-06-19
def move(n, a, b, c):
if n==1:
print 'Take',n,'from',a,'to',c
else:
move(n-1,a,c,b)
print 'Take',n,'from',a,'to',c
move(n-1,b,a,c)
move(4,'a', 'b', 'c')
加上盘子的编号应该会好理解点
if n==1:
print 'Take',n,'from',a,'to',c
else:
move(n-1,a,c,b)
print 'Take',n,'from',a,'to',c
move(n-1,b,a,c)
move(4,'a', 'b', 'c')
加上盘子的编号应该会好理解点
2015-06-19
x1 = 1
d = 3
n = 100
x100 = x1*n+n*(n-1)/2*d
s = x100
print s
d = 3
n = 100
x100 = x1*n+n*(n-1)/2*d
s = x100
print s
2015-06-19
L = range(1,101)
sum=0
for num in L:
sum+=num*num
print sum
shit。这个也不对
sum=0
for num in L:
sum+=num*num
print sum
shit。这个也不对
2015-06-18