zoukankan      html  css  js  c++  java
  • 希尔排序 C#

    1 
     1  class Program

     2     {

     3         static void Main(string[] args)
     4         {
     5             int[] iArrary = new int[] { 151361055992871234753347 };
     6             ShellSorter sh = new ShellSorter();
     7             sh.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 ShellSorter
     2     {
     3         /// <summary>
     4         /// 希尔排序
     5         /// </summary>
     6         public void Sort(int[] list)
     7         {
     8             int inc;
     9             for (inc = 1; inc <= list.Length / 9; inc = 3 * inc + 1) ;
    10             for (; inc > 0; inc /= 3)
    11             {
    12                 for (int i = inc + 1; i <= list.Length; i += inc)
    13                 {
    14                     int t = list[i - 1];
    15                     int j = i;
    16                     while ((j > inc) && (list[j - inc - 1] > t))
    17                     {
    18                         list[j - 1] = list[j - inc - 1];
    19                         j -= inc;
    20                     }
    21                     list[j - 1] = t;
    22                 }
    23             }
    24         }

    25     } 

    乌龟才背着房子过一辈子
  • 相关阅读:
    layui 自定义统一监听事件(大范围)
    layui 自定义个别事件
    Django layui {{ }}冲突解决方法
    sudo apt install ...
    Field XXX in XXXX required a bean of type XXXX that could not be found
    Springboot2+bootstrap-table1.12.1+MybatisPlus3.0 后台物理分页实现
    springboot2在后台打印系统执行的SQL
    @Service注解让spring找到你的Service bean
    接受参数的包装类的数据类型写错报错
    Java 日期转字符串
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/3083619.html
Copyright © 2011-2022 走看看