希尔排序
来源:互联网 发布:中国人口数据 编辑:程序博客网 时间:2024/05/16 06:49
先将代码贴上,后续补充内容。
package com.sufa.test;public class ShellSort {/** * @Title: main * @Description: TODO(这里用一句话描述这个方法的作用) * @param @param args 设定文件 * @return void 返回类型 * @throws */public static void main(String[] args) {// TODO Auto-generated method stubint[] a = { 46, 58, 15, 45, 90, 18, 10, 62 }; shellSort(a); for(int i=0;i<a.length;i++) { System.out.println(a[i]); }}/* * 希尔排序 * */public static void shellSort(int[] data) {int length = data.length;for(int d=length/2;d>=1;d= d/2) {//分组间隔从数组的一半每次再逐步减半for(int c=0;c<length-d;c++){//多个分组内进行排序 //注意,间隔为d的所有数为一组for(int i=c;i<length-d;i=i+d){int j= i+d;if(data[i] > data[j]) {int tmp = data[j];data[j] = data[i];data[i] = tmp;}}}}}}
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- CString常用的成员函数简介(一)
- OpenGL ES 2.0 for iPhone Tutorial 1
- MySql数据库优化方案 MySql参数设置
- JDK版本与eclipse兼容问题
- PB11.5,PB12 web项目初探
- 希尔排序
- CentOS下 Eclipse启动错误
- Oracle Server Architecture Diagram(10g,11g)
- 正则表达式
- 深入理解JDBC的超时设置
- 第二个小问题:QT中MainWindow中style sheet设置背景图片继承问题
- java 设计模式-结构模式之亨元模式
- JSF动态显示列,rich:columns的使用
- ext中Window窗体显示在最前面的解决方法