希尔排序问题

来源:互联网 发布:excel数据复制和移动 编辑:程序博客网 时间:2024/06/10 12:58
int []a={70,53,57,28,30,77,1,76,81,70};
            int nlen = a.Length;
            int gap = nlen / 2;
            int temp;
            while (gap > 0)
            {
                
                for (int i = 0; i < nlen-gap; i++)
                {
                    int j = i + gap;
                    if (a[i] < a[j])
                        {
                            temp = a[i];
                            a[i] = a[j];
                            a[j] = temp;
                        }                       
                }

                gap = gap / 2;

结果:81;77;76;70;70;57;53;28;30;1

求解???为什么是这样,哪里有问题啊??

原创粉丝点击