标签:修改 for 传递 sort 实现 pytho style ble 引用传递
import random a=[random.randint(1,999) for x in range(0,33)] # 冒泡排序,python中数组是按引用传递的,会直接在原数组上修改 def bubbleSort(array): flag = True i=0 while i<len(array) and flag: j=len(array)-1 while j>i: if array[j-1] > array[j]: array[j-1],array[j] = array[j],array[j-1] flag = True j=j-1 i = i + 1 bubbleSort(a) print(a)
标签:修改 for 传递 sort 实现 pytho style ble 引用传递
原文地址:http://www.cnblogs.com/praglody/p/6828085.html