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     } 

    乌龟才背着房子过一辈子
  • 相关阅读:
    redis集群报Jedis does not support password protected Redis Cluster configurations异常解决办法
    redis集群密码设置
    Redis 3.2.4集群实战
    Redis3.2.4 Cluster集群搭建
    redis集群环境的搭建和错误分析
    Centos iptables防火墙关闭启动详解
    动态的表格数据
    ubuntu使用抓包工具,charles
    layer结合art实现弹出功能
    禅道开源版源码安装
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/3083619.html
Copyright © 2011-2022 走看看