lst = [2,5,3,7,1,6,4]
for i in range(len(lst)):
for j in range(len(lst)-1-i):
if lst[j]>lst[j+1]:
temp = lst[j+1]
lst[j+1] = lst[j]
lst[j] = temp
print(lst)
lst = [2,5,3,7,1,6,4]
for i in range(len(lst)):
for j in range(len(lst)-1-i):
if lst[j]>lst[j+1]:
temp = lst[j+1]
lst[j+1] = lst[j]
lst[j] = temp
print(lst)
本文标题:008.冒泡法排序
本文链接:https://www.haomeiwen.com/subject/ldgmtctx.html
网友评论