约瑟夫环
类型:程序题

题目说明

def Josephus(num,gap):
    location_list = [a for a in range(1,num+1)]
    if num ==   1 :
        ①
    else:
        index = 0
        for i in        ②        :
            index = (index + gap - 1 )%        ③
            print("本次淘汰的牌为:",location_list[index])
            del location_list[index]
        print( "最后剩下的牌为:",location_list[        ④        ])
Josephus(8,2)

评分标准

  1. return(2分)

  2. range(num-1(4分)

  3. len(location_list(4分)

  4. 0(2分)

代码编辑器 加载中...
留空使用题目默认限制
{{resultStatus.text}}
正在加载运行记录...
乐编题库AI助手
人工客服
微信扫码联系客服
历史对话
{{ s.title || '未命名对话' }}
{{ s.created_at }}
暂无历史对话
我能帮助你什么?