码迷,mamicode.com
首页 > 编程语言 > 详细

python3----冒泡排序

时间:2018-01-11 19:12:59      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:col   result   冒泡   python   冒泡排序   int   res   array   blog   

 1 array = [1, 6, 7, 2, 9, 4]
 2 for i in range(len(array)-1, 1, -1):
 3     for j in range(0, i):
 4         if array[j] > array[j+1]:
 5             array[j], array[j+1] = array[j+1], array[j]
 6 print(array)
 7 
 8 results:
 9 
10 [1, 2, 4, 6, 7, 9]

 

python3----冒泡排序

标签:col   result   冒泡   python   冒泡排序   int   res   array   blog   

原文地址:https://www.cnblogs.com/jonm/p/8269966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!