#求1-100之和(奇数)
count=0
sum = 0
for x in range(1,101):
if (x%2!=0):
sum+=x
count+=1
print('1-100偶数之和为:%d,共有奇数:%d个'%(sum,count))
100以内的求和 奇数(偶的变式)
最新推荐文章于 2024-11-12 23:16:45 发布
#求1-100之和(奇数)
count=0
sum = 0
for x in range(1,101):
if (x%2!=0):
sum+=x
count+=1
print('1-100偶数之和为:%d,共有奇数:%d个'%(sum,count))