Commit 1cab8241 by BellCodeEditor

auto save

parent e9582570
Showing with 29 additions and 9 deletions
total = [] '''
while True: https://blog.csdn.net/qq_43422201/article/details/87278228
unit= input("请输入:") '''
if unit== 'q': n=int(input('输入数字:'))#输入数字
break a=list(range(1,n+1))#建立一个列表,存放的是号码数
else:
total.append(unit) count=0;#构造一个全局变量,使得其储存每一位报的数
print(total) while len(a)>1:#循环直到列表只剩一个元素
\ No newline at end of file b=a[:]#复制列表,为下一步删除做准备
for i in range(0,len(b)):#在len(b)的次数中,计数,并去除数
count+=1
if count%3==0:#如果报三,则去除a中的这一位
a.remove(b[i])
print(a[0])
count = 0
n=int(input())
nums=list(range(1,n+1))
while len(nums)>1:
# newnums = copy.deepcopy(nums)
newnums=nums[:]
for i in newnums:
count+=1
if count%3==0:
nums.remove(i)
print(nums)
\ No newline at end of file
list_1 =[2434,45455,1,0,-523]
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