冒泡排序
def bubble(li):
tag = 0
for i in range(len(li)-1):
for j in range(len(li)-i-1):
if li[j] > li[j+1]:
li[j], li[j+1] = li[j+1],li[j]
tag = 1
if tag == 0:
return
print(li)
li=[2,3,4,5,6,7,8,9,0,1]
bubble(li)
感谢关注