使用直接排序法对一维数组进行排序

时间:2018-12-04 14:07:45   收藏:0   阅读:192

实现效果:

  技术分享图片

实现原理:

  技术分享图片

实现代码:

        public int[] sory(int[] intArray)
        {
            for (int i = 0; i < intArray.Length;i++ )
            {
                int j = i;
                int temp = intArray[i];
                while((j>0)&&temp>(intArray[j-1])){
                    intArray[j] = intArray[j - 1];
                    j--;
                }
                intArray[j] = temp;
            }
            return intArray;
        }

  

 

原文:https://www.cnblogs.com/feiyucha/p/10063562.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!