经典排序——希尔排序——C语言版

#include 
#include 
#include 

int shell_sort(int s[],int n)
{
    int i,j,temp,d;
    float a,b;
    //int p;
    b=n;
    a=b/2;
    //printf("%f\n",a);
    for(d=ceil(a);d>=1;d=ceil(a))  //d is the increasing range
    {
        for(i=d;i//the num before
            temp=s[j-d];
           while(js[j])
           {
               s[j-d]=s[j];
               j=j+d;
           }
            s[j-d]=temp;
            a=(d)/2;
            /*for(p=0;p

        }
        //printf("%d\n%f\n",d,a);
    }
    return *s;
}


int main()
{
    int s[5];
    int n,i;
    n=5;
    for(i=0;iscanf("%d",&s[i]);
    }
    shell_sort(s,n);
    for(i=0;iprintf("%d ",s[i]);
    }
}

你可能感兴趣的:(2017-5)