python实现选择算法

// python实现选择排序
# 定义选择最大值的函数
def selectionSortFunction(list):
    newlist=[]
    for i in range(len(lsit)):
        maxOne = max(list)
        newlist.append(maxOne)
        list.remove(one)
    return newlist
print(selectionSortFunction(([1,3,0,23,14,25,53,27]))
#输出
[53, 27, 25, 23, 14, 3, 1, 0]

猜你喜欢

转载自blog.csdn.net/weixin_42011265/article/details/84753735