冒泡排序
1 """ 2 冒泡排序 3 """ 4 def bubble_sort(int_list): 5 length = len(int_list) 6 if length <= 1: return int_list 7 for i in range(length - 1): 8 for j in range(length - i - 1): 9 if int_list[j + 1] < int_list[j]: 10 int_list[j + 1], int_list[j] = int_list[j], int_list[j + 1] 11 return int_list 12 13 14 if __name__ == '__main__': 15 int_str = input("请输入逗号分割的整数>>>").strip() 16 int_list = [int(i) for i in int_str.split(",")] 17 print(bubble_sort(int_list))