0
点赞
收藏
分享

微信扫一扫

Python之插入排序

import random
import copy
def insertSort(num):
"""
插入排序
:param num:
:return:
"""
sortL = []
print(num)
for i in range(1, len(num)):
key = num[i]
j = i - 1
while j >= 0 and key < num[j]:
num[j + 1] = num[j]
j -= 1
num[j + 1] = key
sortL.append(copy.deepcopy(num))
# for i in sortL:
# print(i)
  • ​​Python append() 与深拷贝、浅拷贝​​


举报

相关推荐

0 条评论