#选择排序1
def Select_Sort_Simple(list):
list_new = []
for i in range(len(list) - 1):
min_val = min(list)
list_new.append(min_val)
list.remove(min_val)
return list_new
#选择排序2
def Select_Sort(list):
for i in range(len(list) - 1):
for j in range(i+1,len(list)):
if list[j] < list[i]:
list[i],list[j] = list[j],list[i]
print(list)
return list
li = [1, 3, 2, 8, 6, 4, 5, 7]
re = Select_Sort(li)
print(re)
排序算法【02选择排序】python
最新推荐文章于 2023-05-03 09:52:15 发布