鱼C论坛's Archiver
论坛
›
Python交流
› Python: 每日一题 41
nononoyes
发表于 2020-8-21 09:23:06
666
nononoyes
发表于 2020-8-21 10:01:10
str = '1110'
sum =0
count = 0
for i in range(len(str)-1,-1,-1):
if (count+1) % 2 != 0:
sum += int(str)*(2**count)
count+=1
else:
sum -= (int(str)*(2**count))
count+=1
print(sum)
wwwwwise
发表于 2021-4-1 21:42:14
1
页:
1
[2]
查看完整版本:
Python: 每日一题 41