冒泡排序

 1 #!/usr/bin/env python
 2 """a1 = 123
 3 a2 = 456
 4 temp = a1
 5 a1 = a2
 6 a2 = temp
 7 print(a1, a2)
 8 """
 9 # 冒泡排序
10 li = [11,22,33,7,342,432,2,5,14,15,31,55,23,5236]
11 m = 1
12 for t in range(len(li)) :
13     print(t)
14     for i in range(len(li) - m) :
15 
16         temp = li[i]
17         if li[i] > li[i + 1] :
18             li[i] = li[i + 1]
19             li[i + 1] = temp
20             m+=1
21 print(li)

 

posted @ 2017-01-28 13:54  失落的黎明  阅读(147)  评论(0编辑  收藏  举报