大佬们帮忙看看这个程序为什么运行不了
b = 0for i in range(100,1000):
for a in str(i):
a = int(a)
b += pow(a,3)
if b == int(i):
print(b)
每次循环完变量b要初始化 b = 0
for i in range(100,1000):
for a in str(i):
a = int(a)
b += pow(a,3)
if b == int(i):
print(b)
b=0 for i in range(100,1000):
b = 0 #b = 0要放在循环里面,因为每一轮训后之后,b的值都会发生改变
for a in str(i):
a = int(a)
b += pow(a,3)
if b == i:
print(b)
页:
[1]