C#选择排序

来源:互联网 发布:淘宝店铺引流量方法 编辑:程序博客网 时间:2024/06/16 08:07
//int[] a = { 2, 3, 1, 1 };
           //int m = 0;
           //for (int i = 0; i < a.Length - 1; i++)
           //{
           //    m = i;
           //    for (int j = i + 1; j < a.Length; j++)
           //    {
           //        if (a[j] < a[m])//i=1,时第二个for循环只负责比,不负责换1321时,2和1比,1=temp,m=3  a[1]和a[3]换
           //        {
           //            m = j;
           //        }
           //    }
           //    int temp = a[i];
           //    a[i] = a[m];
           //    a[m] = temp;
           //    Console.WriteLine("xia"+m);
           //}

           //for (int i = 0; i < a.Length ; i++)
           //{
           //    Console.WriteLine(a[i ]);
           //}
原创粉丝点击