root@(none):~/python# python maopao.py[6, 11, 13, 22, 99]root@(none):~/python# cat maopao.py #!/usr/bin/env pythonli = [13,22,6,99,11] for m in range(len(li)-1): for n in range(m+1,len(li)): if li[m] > li[n]: temp = li[n] li[n] = li[m] li[m] = temppr…
先学习之前未完成的冒泡算法 li = [13,22,6,99,11] 从小到大 从第一个数字比较把大的往后移位 for m in range(4): num1 = li[m] num2 = li[m+1] if num1 > num2: temp = li[m] li[m] = num2 li[m+1] = temp print li 循环四次就把最大数放到列表的最后 for m in range(3): num1 = li[m] num2 = li[m+1] if num1 > num2:…
array = [1,2,3,6,5,4,28,2,1,9,3,0,200,2,9,3,2,98,33,988,22,0,223,0,33,78,222,88,32,0,238,883,2,0,23] for i in range(len(array)): for j in range(i): if array[j] > array[j + 1]: for jj in range(i): if array[jj] >…
day10 python 1.冒泡算法 冒泡排序,把列表竖起来看,就像一个个气泡往上去(时间复杂度大) lst = [12,3,3,2424,14,3567,534,324,324,23,4,23,42,4324] for num in range(len(lst)): for i in range(len(lst)-1): if lst[i] > lst[i+1]: lst[i], lst[i+1] = lst[i…