插入排序
def insertion_sort(list):
N = len(list)
for i in range(1, len(list)):
for j in range(i, 0, -1):
if list[j] < list[j - 1]:
minnum = list[j]
list[j] = list[j - 1]
list[j - 1] = minnum
nums_list = [1, 2, 4, 3, 9, 6, 5]
insertion_sort(nums_list)
print(nums_list)
浙公网安备 33010602011771号