- 希尔排序也叫缩小增量排序
- 选取增量为 len/2 (不是最佳)
//希尔排序:缩小增量序列排序
void ShellSort(int a[], int len) {
int i, j;
int Increment;//增量
int tmp;
for (Increment = len / 2; Increment > 0; Increment /= 2) {
for (i = Increment; i < len; i++) {
tmp = a[i];
for (j = i; j >= Increment; j -= Increment) {
if (tmp < a[j - Increment]) {
a[j] = a[j - Increment];
}
else
break;
}
a[j] = tmp;
}
}
}