public static void bubbleSort(int[] a) { int temp = 0; for (int i = 0; i <a.Length; i++) { for (int j = a.Length - 1; j > i; j--) { if (a[j] < a[j - 1]) { temp = a[j - 1]; a[j - 1] = a[j]; a[j] = temp; } } } }
冒泡排序时间复杂度O(n2)