希尔排序1.0
2015-08-13 13:05
204 查看
<span style="font-family:Comic Sans MS;font-size:18px;">//shellSort.h #include<iostream> #include<vector> using namespace std; template<typename T> void shellSort(vector<T> &v){ int gap;//步长 int n=v.size();//大小 for(gap=n/2;gap>0;gap=gap/2){ for(int j=0;j<gap;j++){ for(int k=gap+j;k<=(n-1);k+=gap){ for(int m=k;m>j;m=m-gap){ if(v[m-gap]>v[m]) swap1(v[m],v[m-gap]); } } } } } template<typename T> void swap1(T & a,T & b){ auto temp=b; b=a; a=temp; } template<typename T> void show(vector<T> & v){ for(auto p:v) cout<<p<<endl; }</span>
相关文章推荐
- Android Studio 使用 Gradle 打包 Jar
- poj-2406-Power Strings (kmp)
- CSUOJ 赌神的战斗
- git - 简易指南
- windows下动态链接库(讲解)
- Git SSH Key 生成步骤
- hdu1394 Minimum Inversion Number(最小逆序数)
- MySQL子查询慢现象的解决
- 数据库备份与恢复:数据量大的库怎么考虑设计备份策略?
- 简单工厂模式
- 4 - 09. 笛卡尔树(25)
- CentOS下通过yum安装svn及配置
- form提交页设置编码类型,使其数据无乱码 gbk utf-8 转
- servlet学习笔记8——ServletContext的讲解和使用
- [Leetcode 3, Medium] Longest Substring Without Repeating Characters
- 在 scala 中 实现 一个方便序列化的 enumeration 类
- 将linux程序或者脚本的后台运行
- 带百度地图apk 签名打包后 地图key验证失败
- 在centos7下怎么进入单用户状态以便修改root密码
- android ndk入门学习