快速排序python实现
2015-08-28 10:29
681 查看
#--×--coding:utf-8-*- def main(): nlist = [] while 1: tmp = raw_input("Please input your element,end by -1") if int(tmp ) == -1: break nlist.append(tmp) InsertSort(nlist) def InsertSort(nlist): nlistSize = len(nlist) for index in xrange(nlistSize - 1): for currentindex in xrange(index, nlistSize - 1): if nlist[currentindex] > nlist[currentindex + 1]: nlist[currentindex] , nlist[currentindex + 1] = nlist[currentindex +1] > nlist[currentindex] print "排序后的",nlist if __name__ == "__main__": main()
相关文章推荐
- Python中的join()函数和split()函数的用法
- 利用python数组解析ifconfig命令输出
- Python的字符串
- python Built-in Functions(python内置函数)
- 零基础学python-8.4 在原处修改列表方法汇总
- 零基础学python-8.4 在原处修改列表方法汇总
- python dict
- gitignore python 清单
- python中类的定义
- 面向对象编程其实很简单——Python 面向对象(初级篇) 推荐
- python代码`if not x:` 和`if x is not None:`和`if not x is None:`使用
- 推荐几个python学习的好东东!
- WingIDE破解 python2.x和python3.x
- Python中的字符串相关转换
- 深入解析Python中的lambda表达式的用法
- 计蒜客题库(Python):7、奇怪的国家
- 计蒜客题库(Python):7、奇怪的国家
- 计蒜客题库(Python):9、元素移除
- python: local variable 'xxx' referenced before assignment
- Python单元测试框架之pytest---如何执行测试用例