Shell Sort

2019-03-31  本文已影响0人  綿綿_
public class ShellSort {
    static final int SIZE=10;
    public static void Shell(int [] a)
    {
        int i,j;
        int r,temp;
        int x=0;
        
        for(r=a.length/2;r>=1;r/=2)
        {
            for(i=r;i<a.length;i++)
            {
                temp=a[i];
                j=i-r;
                while(j>=0&&temp<a[j])
                {
                    a[j+r]=a[j];
                    j-=r;
                }
                a[j+r]=temp;
            }
            x++;
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读