zoukankan      html  css  js  c++  java
  • [算法]希尔排序

     
            int arry[]={1,4,9,4,8,2,7,43,3,2};
            int acount=sizeof(arry);
            int aocount=sizeof(arry[0]);
            int n=(acount/aocount);
         
            int k;
            k=n/2;
            int t;
            while(k>0)
            {
                for(i=k;i<n;i++)
             {  
                t=arry[i];
                j=i-k;
               while(j>=0&&t<arry[j])
                 {
                     arry[j+k]=arry[j];
                     j=j-k;
                 }
                 arry[j+k]=t;
              }
                 k/=2;
            }
          for (int i=0;i<n;i++) {
                printf("%d",arry[i]);
            }

  • 相关阅读:
    htop命令使用详解
    三月江南
    linux下文本三剑客之sed
    linux下五种查找命令
    Spring MVC 全局异常处理&文件上传
    About Spring MVC
    JSP
    java多线程
    Java中map接口 遍历map
    log4j
  • 原文地址:https://www.cnblogs.com/jinjiantong/p/2981678.html
Copyright © 2011-2022 走看看