插入排序算法代码实现

        //插入排序算法
        private static void sort(int []a)
        {
            int j;
            int temp;
            for(int i = 1;i <a.Length;i++)
            {
                j = i - 1;
                temp = a[i];
                while (temp < a[j] && j >= 0)
                {
                    a[j +1] = a[j];
                    j--;
                }
                a[j + 1] = temp;
            }
        }

posted @ 2017-09-04 16:21  beautifulday  阅读(843)  评论(1编辑  收藏  举报