public class test {
public static void main(String[] args) {
int N = 10;
int[] a = new int[N];
for (int i = 0; i < N; i++) {
a[i] = (int) (Math.random() * 100);
System.out.print(a[i] + "\t");
}
System.out.println();
sort(a, N - 1);
for (int i = 0; i < N; i++) {
System.out.print(a[i] + "\t");
}
}
private static void sort(int[] a, int last) {
for (int space = a.length / 2; space > 0; space--) {
for (int i = 0; i < space; i++) {
for (int j = i + space; j <= last; j += space) {
int temp = a[j];
int k = j;
for (; k - space >= 0 && a[k - space] > temp; k -= space) {
a[k] = a[k - space];
}
a[k] = temp;
}
}
}
}
}