伪代码的列表从1开始,Python 代码要做修改。
# 插入排序
def Insertion_sort(ListA):
n = len(ListA)
for i in range(1,n):
j = i -1
key = ListA[i]
while (j>=0 and ListA[j]>key):
ListA[j+1] = ListA[j]
j = j -1
ListA[j+1]=key
print("第",i,"趟",ListA)
l1 = [55,22,44,11,33]
Insertion_sort(l1)
print("结果",l1)