标题:请大家来看看这个代码,怎样优化的更好!
取消只看楼主
小飞神
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-1-20
结帖率:100%
 问题点数:0 回复次数:0 
请大家来看看这个代码,怎样优化的更好!
def panduanshuchu(intlist, int1list, n) :
    for i in range(0, n) :
        i = int(raw_input("please enter your number:"))
        intlist.append(i)
    s = 0
    while s < n :
        x = 0  
        max = 0
        for i in range(0, n) :
            if intlist[i] != "null" :
                if max < intlist[i] :
                    max = intlist[i]
                    x = i
                elif max == 0 :
                    max = intlist[i]
                    x = i
        int1list.append(max)
        intlist[x] = "null"
        s += 1
   
    while n > 0 :
        print int1list[n-1],
        n -= 1
##########################################################
n = int(raw_input("Please enter the number of input you want to:"))
intlist = []
int1list = []
panduanshuchu(intlist, int1list, n)
搜索更多相关主题的帖子: please number null 
2016-01-20 16:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-461227-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.428676 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved