时间:2021-07-01 10:21:17 帮助过:106人阅读
2.python冒泡排序代码
def bubble(l):
flag = True
for i in range(len(l)-1, 0, -1):
if flag:
flag = False
for j in range(i):
if l[j] > l[j + 1]:
l[j], l[j+1] = l[j+1], l[j]
flag = True
else:
break
print l
li = [21,44,2,45,33,4,3,67]
bubble(li)