/// <summary> /// 选择排序 /// 依次选择最小的数字放到最左边
/// 相对于冒泡排序的优势,移动少—速度快
/// </summary>
/// <param name="arr"></param>
public static void SelectionSort(this int[] arr) { int min, temp; for (int outer = 0; outer < arr.Length; outer++) { min = outer; for (int inner = outer + 1; inner < arr.Length; inner++) { if (arr[inner] < arr[min]) { min = inner; } } temp = arr[outer]; arr[outer] = arr[min]; arr[min] = temp; arr.Show(); } }
标签:10,arr,outer,temp,min,int,选择,inner,排序 From: https://www.cnblogs.com/billzhjh/p/17029949.html