美文网首页
Shell Sort

Shell Sort

作者: 綿綿_ | 来源:发表于2019-03-31 18:52 被阅读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++;
        }
    }

相关文章

网友评论

      本文标题:Shell Sort

      本文链接:https://www.haomeiwen.com/subject/jwpubqtx.html