private int[] array = new int[] {89, 45, 68, 90, 29, 34, 17}; /// <summary> /// 冒泡排序(蛮力法) /// </summary> public void BubbleSort() { for (int i = 0; i < array.Length-1; i++) { for (int j = 0; j < array.Length-1-i; j++) { if (array[j] > array[j+1]) { int temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; } } } } /// <summary> /// 选择排序(蛮力法) /// </summary> public void ChooseSort() { for (int i = 0; i < array.Length-1; i++) { for (int j = i+1; j < array.Length; j++) { if (array[i] > array[j]) { int temp = array[j]; array[j] = array[i]; array[i] = temp; } } } }