冒泡排序
dic = [12, 45, 22, 6551, 74, 155, 6522, 1, 386, 15, 369, 15, 128, 123, ] for j in range(1, len(dic)): for i in range(len(dic)-j): if dic[i] > dic[i+1]: temp = dic[i] dic[i] = dic[i+1] dic[i+1] = temp print(dic)
时间: 2024-10-31 08:15:04
冒泡排序
dic = [12, 45, 22, 6551, 74, 155, 6522, 1, 386, 15, 369, 15, 128, 123, ] for j in range(1, len(dic)): for i in range(len(dic)-j): if dic[i] > dic[i+1]: temp = dic[i] dic[i] = dic[i+1] dic[i+1] = temp print(dic)