#-*-coding:UTF-8-*-
def insertsort(numlist):
length = len(numlist)
for j in range(1, length):
key=numlist[j]
k = j-1
while k>=0 and key > numlist[k]:
numlist[k+1] = numlist[k]
k=k-1
numlist[k+1]=key
numlist = [10,9,8,7,6,5,4,3,22,34,46]
insertsort(numlist)
print numlist
算法导论插入排序算法python实现
最新推荐文章于 2024-03-02 10:04:41 发布