n = 100
sum = 0
counter = 1
while counter <= n:
sum = sum + counter
counter += 1
print("1 到 100之和为:" sum)
n = 100
sum = 0
counter = 1
while counter <= n:
sum = sum + counter
counter += 1
print("1 到 100之和为:" sum)
本文标题:使用了 while 来计算 1 到 100 的总和:
本文链接:https://www.haomeiwen.com/subject/etdmdftx.html
网友评论