求大神指导这是怎么回事?
//使用希尔排序法将如下数字由大到小进行排序,数字分别为45,68,12,32,7,85,456,258,123,357.#include <stdio.h>
void sort(int s[],int);
int main(void)
{
int i,a[10]={45,68,12,32,7,85,456,258,123,357};
sort(a,10);
printf("the sorted array:\n");
for(i=0;i<10;i++)
printf("%d ",a[i]);
}
void sort(int s[],int n)
{
int i,j,d;
d = n/2;
while(d >= 1)
{
for(i = d + 1; i < n; i++)
{
j = i - d;
while(s[i] > s[j]&&j>0)
{
s[j + d]=s[j];
j = j - d;
}
s[j + d] = s[i];
}
d = d/2;
}
}
输出结果为:45 68 12 12 7 7 7 7 7 7