标签:
插入排序:直接插入排序、希尔排序、二分插入排序
1.直接插入排序
public static void sort(int[] arr) { int length = arr.length; for (int i = 1; i < length; i++) { for (int j = i; j > 0 && arr[j] < arr[j - 1]; j--) { int temp = arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; } System.out.print("第" + i + "次:"); for (int k = 0; k < length; k++) { System.out.print(arr[k] + ","); } System.out.println(); } }
2.希尔排序
标签:
原文地址:http://www.cnblogs.com/wanshi1989/p/5408493.html