python实现:题⽬:有n个⼈围成⼀圈,顺序排号。从第⼀个⼈开始报数(从1到3报数),凡。。。
count = int(input('Please input the count:'))
li = []
for i in range(count):
li.append(i+1)
times = count//3 +2
count_tial = 0
for i in range(times):
for j in range(count_tial+1,len(li)+count_tial+1):
if count_tial == 2:
li[0] = 0
if (j - count_tial) < len(li) and (j+1)%3 == 0:
li[j - count_tial] = 0
count_0 = li.count(0)
try:
count_tial = len(li) - li.index(0,len(li)-3,len(li))-1
except Exception as e:
html实现用户注册登录代码break
for i in range(len(li)):
try:
except:pass
if len(li) == 2:
print('\n  ! ! ! The last is:',li[1],' ! ! !')
else:print('\n  ! ! ! The last is:',li[0],' ! ! !')
# print('\n(last li:',li,')')

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。