冒泡算法

li=[1,4,7,9,2,6,8,]
for j in range(1,len(li)):
for i in range(len(li)-j):
if li[i]>li[i+1]:
temp=li[i]
li[i]=li[i+1]
li[i+1]=temp
print(li)
posted @ 2017-10-28 11:23  python学到老  阅读(134)  评论(0)    收藏  举报