希尔排序_Java
来源:互联网 发布:水利工程量绘图软件 编辑:程序博客网 时间:2024/05/19 19:56
public class Sort006 {
public static void shellSort(int [] a){
int gap = a.length/2;
while(gap >0){
for(int i=0;i<a.length;i++){
for(int j=i+gap;j<a.length;j++){
if(a[j]<a[i]){
int temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
gap = gap/2;
}
}
public static void main(String [] args){
int [] a={5,11,9,8,7,6,0,1,3,2};
shellSort(a);
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
}
}
public static void shellSort(int [] a){
int gap = a.length/2;
while(gap >0){
for(int i=0;i<a.length;i++){
for(int j=i+gap;j<a.length;j++){
if(a[j]<a[i]){
int temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
gap = gap/2;
}
}
public static void main(String [] args){
int [] a={5,11,9,8,7,6,0,1,3,2};
shellSort(a);
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
}
}
0 0
- 希尔排序_Java
- 希尔排序_Java
- 基本排序_希尔排序_Java实现
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 【Python开发】PyInstaller打包Python程序
- MySQL InnoDB的一致性非锁定读
- 京东实用待产清单!有了大宝的经验,杜绝浪费~
- javascript array.forEach()和array.map()的区别
- lintcode(638)Strings Homomorphism
- 希尔排序_Java
- Android 加载assets文件夹下带有css的html文件,无法显示网络请求的结果,原因是onReceiveSslError问题
- Java中hashCode的作用
- 解决报错:java.lang.NoSuchMethodException: com.tangyuan.entity.RicherProduct.<init>()
- Java异常finally语句
- 如何手动对apk进行签名?
- JCO连接SAP例子
- 队列ADT
- 解决RecyclerView.getChildAt(Position)崩溃