摘要:
public class MergeSort { private static void mergeSortTest() { int[] in = { 2, 5, 3, 8, 6, 7, 1, 4, 0, 9 }; Utils.printArray("归并排序前:",in); int a[] = mergeSort(in); Utils.printArray("归并排序后:",a); } private static int[] mergeSort(int[] arr) { if (arr.length == 1) { return arr; } els 阅读全文
posted @ 2014-03-11 21:00
zhaofeng555
阅读(137)
评论(0)
推荐(0)
摘要:
public class InsertSortUtils { public static void main(String[] args) { insertSortTest(); shellSortTest(); } private static void insertSortTest() { int[] values = { 5, 2, 4, 1, 3 }; System.out.print("直接插入排序前: "); Utils.printArray(values); insertSort(values); System.out.print("直接插入排序后: 阅读全文
posted @ 2014-03-11 20:59
zhaofeng555
阅读(144)
评论(0)
推荐(0)
摘要:
public class ExchangeSortUtils { // 冒泡 public static void bubbleSort(int[] array) { int length = array.length; int temp; boolean isSort; for (int i = 1; i array[j + 1]) { // 交换 temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; isSort = true; } } if (!isSo... 阅读全文
posted @ 2014-03-11 20:58
zhaofeng555
阅读(300)
评论(0)
推荐(0)
摘要:
public class SelectionSort { private static void selectSortTest() { int[] sortArray = { 5, 2, 4, 1, 3 }; System.out.print("选择排序前: "); Utils.printArray(sortArray); selectSort(sortArray); System.out.print("选择排序后: "); Utils.printArray(sortArray); } public static void selectSort(int[ 阅读全文
posted @ 2014-03-11 20:56
zhaofeng555
阅读(142)
评论(0)
推荐(0)
浙公网安备 33010602011771号