Commit 9f750221 by BellCodeEditor

auto save

parent 5ec53ebb
Showing with 40 additions and 0 deletions
n = int(input("总人数:"))
num = []
for i in range(n):
num.append(i+1)#从1开始来输入编号
print(num)
i = 0#循环变量,用来推动循环的进行
k = 0#k取值为1,2,3,用来判断这一位置的num[i]是否需要出列
m = 0#退出的人数
while m<n-1:
if num[i] != 0:#如果当前的数值不为0表示没有出列的编号,可以让k增加1
k+=1
if k == 3:#当k增加到3时表示这一位置的num[i]正好报到3,需要出列
num[i] = 0#赋值为0表示出列
k = 0#重新计算
m+=1#退出人数进行改变
i+=1#改变循环变量,推动程序进行
if i == n: i = 0#如果循环变量到最后则改变循环变量
i = 0#从0开始,看看哪个不是0,则为没有退出的人
while num[i] == 0: i+=1 #如果i等于0则让i进行滚动
print(num[i])#输出没有退出队列的编号
\ No newline at end of file
with open(r'c:\Users\bell\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as f:
#获取多行数据使用readlines(),以列表的形式将所有的数据读取进来,每一行内容都会成为返回列表的一个数据
a = f.read().split('\n')
print(a)
\ No newline at end of file
悟空:348
诺依:380
小贝:182
李丽:201
宋扬:107
王明:245
李强:164
孙小白:222
苏琪:137
刘若若:147
刘阳:226
王胜男:123
王娇:131
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment