冒泡排序

li = [21,3,4,58,6]
for n in range(1,len(li)):
    # print(n)
# print(li)
    for s in range(len(li)-n):
        # print(s)
        if li[s] > li[s+1]:
            ret = li[s]
            li[s] = li[s+1]
            li[s+1] = ret
print(li)

 

posted @ 2017-11-09 23:13  口水哥  阅读(122)  评论(0编辑  收藏  举报