package com.lz.demo1;
/**
* <p>
* 希尔排序
* </p>
*
* @author ZLi 2016-8-4
*
*/
public class ShellSort {
public static void main(String[] args) {
int array[] = { 1, 54, 6, 3, 78, 34, 12, 45, 56, 100 };
int length, d, temp;
length = array.length;
d = length / 2;
temp = 0;
while (d > 0) {
for (int i = d; i < length; i++) {
int j = i - d;
temp = array[i];
while (j >= 0 && array[j] > temp) {
array[j + d] = array[j];
j = j - d;
}
array[j + d] = temp;
}
d = d / 2;
}
for (int i : array) {
System.out.println(i);
}
}
}