请问代码里面i跟flag的值1和0分别代表什么?(请看补充)
x=7i=1flag=0whilei<=100:if(x%2==1)and(x%3==2)and(x%5==4)and(x%6==5):flag=1else:x=7*(i...
x = 7
i = 1
flag = 0
while i <= 100:
if (x%2 == 1) and (x%3 == 2) and (x%5 == 4) and (x%6==5):
flag = 1
else:
x = 7 * (i+1) # 根据题意,x一定是7的整数倍,所以每次乘以7
i += 1
if flag == 1:
print('阶梯数是:', x)
else:
print('在程序限定的范围内找不到答案!') 展开
i = 1
flag = 0
while i <= 100:
if (x%2 == 1) and (x%3 == 2) and (x%5 == 4) and (x%6==5):
flag = 1
else:
x = 7 * (i+1) # 根据题意,x一定是7的整数倍,所以每次乘以7
i += 1
if flag == 1:
print('阶梯数是:', x)
else:
print('在程序限定的范围内找不到答案!') 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询