/// <summary> /// 选择排序--递归写法 /// </summary> /// <param name="data">数组</param> /// <param name="start">开始下标</param> /// <param name="end">结束下标</param> public void selectSort(int[] data, int start, int end) { int temp = 0; if (start >= end) return; for (int i = start + 1; i <= end; i++) { if (data[i] < data[start]) { temp = data[i]; data[i] = data[start]; data[start] = temp; } } selectSort(data, start + 1, end); } /// <summary> /// 冒泡排序 /// </summary> /// <param name="data">数组</param> public void bubbleSort(int[] data) { int temp = 0; for (int j = 0; j < data.Length - 1; j++) { for (int i = 0; i < data.Length - j - 1; i++) { if (data[i] > data[i + 1]) { temp = data[i]; data[i] = data[i + 1]; data[i + 1] = temp; } } } }