标签:sort use style nbsp logs stat void bubble 排序算法
public int get_middle(int[] list, int low, int high){ int tmp = list[low]; while(low < high){ while(low < high && list[high]>tmp){ high --; } list[low] = list[high]; while(low < high && list[low] < tmp){ low ++; } list[high] = list[low]; } list[low] = tmp; return low; } public void quick_sort(int[] list, int low, int high){ int middle = get_middle(list, low, high); quick_sort(list, low, middle-1); quick_sort(list, middle+1, high); } public void use_quick_sort(int[] list){ if (list.length > 1){ quick_sort(list, 0, list.length-1); } } public static void bubble_sort(int[] list) { int temp = 0; for (int i = list.length - 1; i > 0; --i) { for (int j = 0; j < i; ++j) { if (list[j] > list[j + 1]) { temp = list[j + 1]; list[j + 1] = list[j]; list[j] = temp; } } } }
标签:sort use style nbsp logs stat void bubble 排序算法
原文地址:http://www.cnblogs.com/yunmenzhe/p/7682927.html