首页 > 编程语言 > 详细

python数据结构之热土豆问题(队列得应用)

时间:2020-05-11 09:01:56      阅读:123      评论:0      收藏:0      [点我收藏+]
from 队列的构造 import *


def hotPotato(namelist,num):
    simqueue=Quene()
    for name in namelist:
        simqueue.enquene(name)
    while simqueue.size()>1:
        for i in range(num):
            simqueue.enquene(simqueue.dequene())
        simqueue.dequene()
    return simqueue.dequene()

print(hotPotato([bill,david,suan,das,fddsfs],3))

 

python数据结构之热土豆问题(队列得应用)

原文:https://www.cnblogs.com/ares-python/p/12866939.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!