namespace Sort
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 2,6,1,9,3,7,0,8,5,4};
            //print
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i]+"   ");
            }
            Console.WriteLine("\n---------------------------------------");
            Console.WriteLine("After sort:");
            Console.WriteLine("---------------------------------------");

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


            //print
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + "   ");
            }

            Console.ReadLine();
        }
    }
}

posted on 2013-10-28 22:27  zzunstu  阅读(219)  评论(2编辑  收藏  举报