print("1000")
1 比较判断
he = 0
i = -1
while he<=100:
i = int(input("请输入一个整数"))
he += i
print(he)
2 利用标志位
he = 0
i = -1
flag = True
while flag:
i = int(input("请输入一个整数"))
he += i
if he>100:
flag = false
print(he)
3 利用break
he = 0
i = -1
flag = True
while flag:
i = int(input("请输入一个整数"))
he += i
if he>100:
break
print(he)
方法一:
he = 0
i = -1
while he <= 100 :
i = int(input('input int:'))
he += i
print(he)
方法二:用标注位
he = 0
i = -1
flag = True
while he <= 100 :
i = int(input('input int:'))
he += i
if he>100:
flag = False
print(he)
方法三:利用break
he = 0
i = -1
while True :
i = int(input('input int:'))
he += i
if he>100:
break
print(he)