希尔排序
来源:互联网 发布:数控g92螺纹编程实例 编辑:程序博客网 时间:2024/06/12 01:27
package com.paixu;
public class SheelSrot {
public int[] sheelSort(int[] src){
int l ;
for(int dk = src.length/2;dk>0;dk/=2){
for(int i=dk;i<src.length;i++){
int j=i-dk;
l = src[i];
while((j>=0)&&(l<src[j])){
src[j+dk] = src[j];
j -= dk;
}
src[j+dk] = l;
}
}
return src;
}
public static void main(String[] args) {
int[] src1 = {49,38,65,97,76,13,27,49};
int[] src = new SheelSrot().sheelSort(src1);
for(int i=0;i<src.length;i++){
System.out.print(src[i]+" ");
}
}
}
public class SheelSrot {
public int[] sheelSort(int[] src){
int l ;
for(int dk = src.length/2;dk>0;dk/=2){
for(int i=dk;i<src.length;i++){
int j=i-dk;
l = src[i];
while((j>=0)&&(l<src[j])){
src[j+dk] = src[j];
j -= dk;
}
src[j+dk] = l;
}
}
return src;
}
public static void main(String[] args) {
int[] src1 = {49,38,65,97,76,13,27,49};
int[] src = new SheelSrot().sheelSort(src1);
for(int i=0;i<src.length;i++){
System.out.print(src[i]+" ");
}
}
}
0 0
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 直接插入排序
- 网站收录
- Maximum Product Subarray
- mfc onsize() 乱序
- 前序遍历中序遍历求后序遍历-数组篇
- 希尔排序
- NSIS的安装程序在Windows Server 2012下呈现不响应的状态
- [转载]activiti5.13 框架 数据库设计说明书
- 记一次JVM GC日志分析
- 【BZOJ1036】[ZJOI2008]树的统计Count 树链剖分
- 关于java集合Set的一点记录
- grep命令
- 微软首款内置中文Cortana智能手机大陆上市
- Latex 学习7:typing fractions, square roots, and integrals