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

快速排序python实现

时间:2015-08-28 10:53:58      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

#--×--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实现

标签:

原文地址:http://www.cnblogs.com/hackerl/p/4765733.html

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