#include <stdio.h>
#include <stdbool.h>
void show(int A[],int n)
{
for(int i = 1;i<n;i++)
{
printf("%d\n",A[i]);
}
}
void ShellSort(int A[],int n)
{
int j,i,d;
for(d = n/2;d>=1;d=d/2)
{
for(i = d+1;i<=n;i=i++)//都要排
{
if(A[i]<A[i-d])
{
A[0]=A[i];
for(j = i-d;j>0&&A[0]<A[j];j=j-d)
A[j+d]=A[j];
A[j+d]=A[0];
}
}
}
}
int main()
{
int A[5];
A[1]=4,A[2]=3,A[3]=1,A[4]=2;
ShellSort(A,5);
show(A,5);
return 0;
}
07-08
3878
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)