zoukankan      html  css  js  c++  java
  • 插入排序 C#

    1.

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


    2.


      1    class InsertionSorter

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

    乌龟才背着房子过一辈子
  • 相关阅读:
    Discuz X3.2 分区 gid 完美伪静态方法 Apache/Nginx
    如何批量转换 WordPress 文章分类
    修改 WordPress 文件上传目录
    如何验证 jemalloc 优化 Nginx 是否生效
    .Net Core 1.1 + CentOs 7 环境配置
    DotNet Core中使用dapper
    爬虫 HttpHelper
    iTextSharp 不适用模板 代码拼接PDF
    .Net中的加密解密
    .Net Core使用 MiniProfiler 进行性能分析
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/3083618.html
Copyright © 2011-2022 走看看