java语言
package sort_algorithm;
/**
* @Description
* @auther movw
* @create 2019-02-14 10:55
* @package sort_algorithm
*/
public class ShellSort {
public static void shellSort(int[] shellSource){
int i,j,h;
int r,temp;
int x=0;
for(r=shellSource.length/2;r>=1;r/=2){//分组
for(i=r;i<shellSource.length;i++){//插入排序
temp=shellSource[i];
j=i-r;
while (j>=0&&temp<shellSource[j]){
shellSource[j+r]=shellSource[j];
j-=r;
}
shellSource[j+r]=temp;
}
x++;
}
}
public static void main(String[] args) {
int[] a={2,3,1,5};
ShellSort.shellSort(a);
for (int aa:a){
System.out.println(aa);
}
}
}