冒泡排序
1.冒泡排序
public static void BubbleSort(int[] arr) { int i = arr.Length - 1; int last = 0; while (i > 1) { last = 0; for (int j = 0; j < i; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; last = j; } } i = last; } }