冒泡排序算法-Python实现
2015-09-23 11:14
501 查看
#-*- coding: UTF-8 -*- import numpy as np def BubbleSort(a): for i in xrange(0, a.size): for j in xrange(i,a.size): if a[j] < a[i]: a[i], a[j] = a[j], a[i] if __name__ == '__main__': a = np.random.randint(0, 10, size = 10) print "Before sorting..." print "---------------------------------------------------------------" print a print "---------------------------------------------------------------" BubbleSort(a) print "After sorting..." print "---------------------------------------------------------------" print a print "---------------------------------------------------------------"
相关文章推荐
- 选择排序算法-python实现
- 快速排序算法-python实现
- python字典按照值排序
- python 时间模块小结
- Python科学计算发行版—Anaconda
- Python json.dumps
- 解决 python用 xlsxwrite 向excel 中写入中文字符串变量 报错
- Python环境及robotframework安装
- python中str函数isdigit、isdecimal、isnumeric的区别
- Python 爬虫进阶必须的几步
- Python特殊语法:filter、map、reduce、lambda
- Python yield 使用浅析
- 【Python之旅】第三篇(二):Pickle序列化
- python模拟用户登录某某网
- python encode和decode函数说明
- the file opeartion in python(一)
- Python多线程编程之多线程加锁
- Python 使用 OS 模块实现目录遍历
- Python基础语法_运算符详解
- Python之列表推导式