def bubbling_sort(lists):
count = len(lists)
for i in range(0,count):
for j in range(i+1,count):
if lists[i]>lists[j]:#当i=0,j=1 第0个数和第1个数比较
lists[i],lists[j] = lists[j],lists[i]
return lists
lists =[2,1,6,5,9,6,4,3]
for i in bubbling_sort(lists):
print(i,end =" ")
冒泡排序
最新推荐文章于 2022-04-29 23:24:15 发布