public static void sort(int[] a) {
int h = 1;
while (h < a.length / 3) {
h = h * 3 + 1;
}
int temp = 0, j = 0;
while (h >= 1) {
for (int i = h; i < a.length; i++) {
temp = a[i];
for (j = i; j >= h && a[j - h] >= temp; j -= h) {
a[j] = a[j - h];
}
a[j] = temp;
}
h = (h - 1) / 3;
}
}
希尔排序
最新推荐文章于 2023-09-23 16:26:22 发布