zoukankan      html  css  js  c++  java
  • 选择排序 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     } 

    乌龟才背着房子过一辈子
  • 相关阅读:
    求10个随机数的最大值、最小值、和、平均值
    设计并编写代码自动格斗类游戏
    用while实现阶乘
    安卓第三次作业
    第二次作业
    第一次作业
    第四次作业
    dialog
    用画图的方法理解原型对象和原型链,事半功倍今晚不加班
    【学习笔记】浅析Promise函数
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/3083606.html
Copyright © 2011-2022 走看看