Python实现冒泡排序

发布时间:2019-09-19 08:02:35编辑:auto阅读(1775)

    #!/usr/bin/python
    # -*- coding:UTF-8 -*-

    def maopao(numbers):
        for j in xrange(len(numbers)-1,-1,-1):
            for i in xrange(j):
                if(numbers[i] > numbers[i+1]):
                    numbers[i],numbers[i+1] = numbers[i+1],numbers[i]
                    print numbers
                   
    def main():
        number = raw_input("enter some num seperate with split").split(",")
        maopao(number)

    if __name__ == '__main__':
        main()

     

     

关键字

上一篇: Python file 方法

下一篇: ubuntu gns3 与vbox连接