笨小孩做开发

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
    int[] array = { 2, 4, 5, 9, 1, 3, 5, 6, 7 };
            int temp = 0;
            for (int i = 0; i < array.Length - 1; i++)
            {
                for (int j = i + 1; j < array.Length; j++)
                {
                    if (array[j] < array[i])
                    {
                        temp = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                    }
                }
            }
            for (int i = 0; i < array.Length; i ++ )
            {
                Console.WriteLine(array[i]);
            }
posted on 2013-04-01 09:39  笨小孩做开发  阅读(127)  评论(0编辑  收藏  举报