标签:sort 最小值 重复 算法 ber 选择排序 div data- hid
1 def findsmallest(d): 2 smallest = d[0] 3 smallest_number = 0 4 for i in range(1,len(d)): 5 if smallest > d[i]: 6 smallest = d[i] 7 smallest_number = i 8 return smallest_number 9 10 def selectionsort(M): 11 N = [] 12 for j in range(0,len(M)): 13 x=M.pop(findsmallest(M)) 14 N.append(x) 15 return N 16 17 K=[5,8,6,7,2,3,4,9] 18 print(selectionsort(K))
标签:sort 最小值 重复 算法 ber 选择排序 div data- hid
原文地址:https://www.cnblogs.com/FerrisFu/p/9071250.html