num =1
sum =0
while num <=99:
if num % 2 ==1:
sum = sum + num
num =num +1
print(sum)
2.求1-2+3-4+5...99的所有数的和
num =1
sum =0
while num <=99:
if num % 2 ==1:
sum = sum + num
else:
sum =sum -num
num =num +1
print(sum)
2024-03-02 20:24:22
num =1
sum =0
while num <=99:
if num % 2 ==1:
sum = sum + num
num =num +1
print(sum)
2.求1-2+3-4+5...99的所有数的和
num =1
sum =0
while num <=99:
if num % 2 ==1:
sum = sum + num
else:
sum =sum -num
num =num +1
print(sum)