sum = 0 for i in range(1, 102, 2): if (i // 2) % 2 == 0: sum += i else: sum -= i print(sum)
编写程序,求 1 - 3 + 5 - 7 + 9 -11 + 13 - 15 ... - 99 + 101 的值
最新推荐文章于 2022-10-30 23:51:43 发布
sum = 0 for i in range(1, 102, 2): if (i // 2) % 2 == 0: sum += i else: sum -= i print(sum)