赞
踩
people={} for x in range(1,31): #遍历1-30列表 people[x]=1 check=0 #现在下船的人数 i=1 #默认从1开始 j=0 #要下船的人数 while 1: if i == 31: #当报数到31时 i重新回到1 i=1 elif j == 15: #直到15个人下完停止循环 break else: if people[i] == 0: i+=1 continue else: check+=1 if check == 9: people[i]=0 check = 0 j+=1 print("%d号需下船"%i) else: i+=1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。