注册 登录
编程论坛 Python论坛

请大家来看看这个代码,怎样优化的更好!

小飞神 发布于 2016-01-20 16:31, 4311 次点击
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)
0 回复
1