排序算法(四)
package sort;public class ShellSort {public static void shellSort(int[] numbers){int d = numbers.length;do{d = (d+1)/2;shellPass(numbers, d);}while(d > 1);}private static void shellPass(int[] numbers,int d){for(int i = 0 ; i<d; i ++){for(int k = i; k < numbers.length;k+=d){int min = numbers[k],mink = k;for(int j = k+d;j<numbers.length;j+=d){if(numbers[j] < min){min = numbers[j];mink = j;}}if(k != mink){numbers[mink] = numbers[k];numbers[k] = min;}}}}public static void main(String[] args) {int[] numbers = {49,38,65,97,76,13,27,49,55,4};shellSort(numbers);for (int i : numbers) {System.out.print(i + " ");}}}?