C# 顺序表操作

虽然.NET已经是现实了Reverse(),但是学习算法有必要知道其是怎么实现的:

private static void ReverseArray(int[] array)
        {
            int temp;
            int count = array.Length;
            for (int i = 0; i < count / 2; i++)
            {
                temp = array[count - 1 - i];//count-1:最大元素的索引
                array[count - 1 - i] = array[i];
                array[i] = temp;
            }
        }

  

 

posted @ 2014-05-28 16:04  等待是一生最初的苍老  阅读(221)  评论(0编辑  收藏  举报