#include<stdio.h>
int main()
{
int a[10] = {49, 38, 65, 97, 26, 13, 27, 49, 55, 4};
int i, j, gap, n = 10;
for (gap = n / 2; gap > 0; gap /= 2)
{
for (j = gap; j < n; j++)//从数组第gap个元素开始
{
if (a[j] < a[j - gap])//每个元素与自己组内的数据进行直接插入排序
{
int temp = a[j];
int k = j - gap;
while (k >= 0 && a[k] > temp)
{
a[k + gap] = a[k];
k -= gap;
}
a[k + gap] = temp;
}
}
}
for (i = 0; i < n; i++)
printf("%d ",a[i]);
return 0;
}