求1-2+3-4+5 ... 99的所有数的和 # sum = 0 # count = 1 # while count < 100: # if count % 2 == 0: # sum = sum - count # else: # sum = sum + count # count += 1 # print(sum) # sum=0 # for i in range(1,100): # if i%2==0: # sum=sum-i # else: # sum+=i # print(sum)
求1-2+3-4+5 ... 99的所有数的和 # sum = 0 # count = 1 # while count < 100: # if count % 2 == 0: # sum = sum - count # else: # sum = sum + count # count += 1 # print(sum) # sum=0 # for i in range(1,100): # if i%2==0: # sum=sum-i # else: # sum+=i # print(sum)
转载于:https://www.cnblogs.com/wgzzk/p/10967756.html