• 多线程加上简单的冒泡算法


    # -*- coding: utf-8 -*-
    import _thread
    from time import sleep, ctime

    def fun1():
    sleep(2)
    print('aaaaaaaaaa')

    def fun2():
    sleep(1)
    print('bbbbbbbbb')

    def main():
    _thread.start_new_thread(fun1,())
    _thread.start_new_thread(fun2,())
    sleep(5)
    print('end')

    main()

    #------------带参数-------------------------
    # -*- coding: utf-8 -*-
    import _thread
    from time import sleep, ctime

    def fun1(page):
    sleep(2)
    print('aaaaaaaaaa=%i'%page)

    def fun2(page):
    sleep(1)
    print('bbbbbbbbb=%i'%page)

    def main():
    page=1
    _thread.start_new_thread(fun1,(page,))
    page=2
    _thread.start_new_thread(fun2,(page,))
    sleep(5)
    print('end')

    main()


    冒泡

    arr = (53, 16, 99, 1, 72, 19, 25, 33, 37)
    arr=list(arr)
    arrlen = len(arr)
    for a in range(arrlen):
    for b in range(a + 1, arrlen):
    if (arr[a] > arr[b]):
    temp = arr[a]
    arr[a] = arr[b]
    arr[b] = temp

    print(arr)

  • 相关阅读:
    上采样和下采样
    二、决策树算法
    一、实现贝叶斯算法
    Centos7 安装vscode
    Centos安装IDEA
    Centos设置自带中文输入法
    Centos 安装mysql
    Centos,tomcat
    Centos 7 安装JDK
    Centos7 安装rar,unrar,zip,unzip
  • 原文地址:https://www.cnblogs.com/MRASdoubleZ/p/7840960.html
Copyright © 2020-2023  润新知