# 1+2+3+4+5+6+.....+100 = ? #关键在于,当n为时,才print(s) n = 1
s = 0
while n < 101:
s = s + n
if n ==100: #关键在于这一步, 我用if来判断,当n为100时,才print(s), 否则继续while循环
print(s)
n = n + 1
2024-04-05 12:32:42
# 1+2+3+4+5+6+.....+100 = ? #关键在于,当n为时,才print(s) n = 1
s = 0
while n < 101:
s = s + n
if n ==100: #关键在于这一步, 我用if来判断,当n为100时,才print(s), 否则继续while循环
print(s)
n = n + 1
下一篇:PAT 1042 字符统计