#include <stdio.h>
const unsigned int N = 4; // 下面数组的长度
const unsigned int SellNum[N] = {11, 7, 3, 1}; // 最后一个数值必须是 1
void ShellSort(int* arr, int length) {
for(int n=0; n<N; n++) {
int increase=SellNum[n];
for(int i=0; i<increase; i++) {
for(int j=i+increase; j<length; j+=increase) {
for(int k=j; k-increase>=0 && arr[k-increase]>arr[k]; k-=increase) {
int temp = arr[k];
arr[k] = arr[k-increase];
arr[k-increase] = temp;
}
}
}
}
}
int main(void)
{
int a[] = {3, 1, 3, 63, 11,2, 5,23, 51};
ShellSort(a, 9);
for(int i=0; i<9; i++) {
printf("%d ", a[i]);
}
}