static void Main(string[] args)
        {
            int[] temp = { 3, 1, 7, 5, 8, 4, };

            int tmps = temp[0];
            for (int i = 1; i < temp.Length; i++)
            {
                for (int j = 1; j <= temp.Length - i; j++)
                {
                    if (temp[j - 1] > temp[j])
                    {
                        tmps = temp[j - 1];
                        temp[j - 1] = temp[j];
                        temp[j] = tmps;
                    }
                }
            }
            for (int i = 0; i < temp.Length; i++)
            {
                Console.WriteLine(temp[i]);
            }

            Console.Read();
        }
posted on 2019-11-04 09:47  .net之路  阅读(82)  评论(0编辑  收藏  举报