# Python实现冒泡排序 def bubble(l): for i in range(len(l))[::-1]: for j in range(i): if l[j] > l[j + 1]: l[j], l[j + 1] = l[j + 1], l[j] return l L = [1, 45, 56, 0, 23, 13, 4, 14, 89, 23, 39, 34, 13, 40, 45, 23] l = bubble(L) print(l)
# Python实现冒泡排序 def bubble(l): for i in range(len(l))[::-1]: for j in range(i): if l[j] > l[j + 1]: l[j], l[j + 1] = l[j + 1], l[j] return l L = [1, 45, 56, 0, 23, 13, 4, 14, 89, 23, 39, 34, 13, 40, 45, 23] l = bubble(L) print(l)