• 选择排序 C#


    1.

     1  class Program
     2     {
     3         static void Main(string[] args)
     4         {
     5             int[] iArrary = new int[] { 1536105592871234753347 };
     6             SelectionSorter ss = new SelectionSorter();
     7             ss.Sort(iArrary);
     8             for (int m = 0; m < iArrary.Length; m++)
     9             {
    10                 Console.Write("{0} ", iArrary[m]);
    11             }
    12             Console.ReadLine();
    13        }  

    14     }


     2.选择排序

     1   class SelectionSorter
     2     {
     3         private int min;
     4         /// <summary>
     5         /// 选择排序
     6         /// </summary>
     7         public void Sort(int[] list)
     8         {
     9             for (int i = 0; i < list.Length - 1; i++)
    10             {
    11                 min = i;
    12                 for (int j = i + 1; j < list.Length; j++)
    13                 {
    14                     if (list[j] < list[min])
    15                         min = j;
    16                 }
    17                 int t = list[min];
    18                 list[min] = list[i];
    19                 list[i] = t;
    20             }
    21         }

    22     } 

    乌龟才背着房子过一辈子
  • 相关阅读:
    8VC Venture Cup 2016
    8VC Venture Cup 2016
    8VC Venture Cup 2016
    HDU 5627 Clarke and MST &意义下最大生成树 贪心
    HDU 5626 Clarke and points 平面两点曼哈顿最远距离
    《花开物语》观后感
    Codeforces Round #146 (Div. 1) B. Let's Play Osu! dp
    Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
    Educational Codeforces Round 7 E. Ants in Leaves 贪心
    Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/3083606.html
Copyright © 2020-2023  润新知