插入排序算法
来源:互联网 发布:是焉得为大丈夫乎的得 编辑:程序博客网 时间:2024/06/15 09:48
package com.test;
/**
* @ClassName: InsertSort.java
* @Description: 插入排序算法
* @author Bert
* 2014-4-3 下午9:00:03
*/
public class InsertSort {
public static void main(String[] args) {
int temp ;
for (int i = 0; i < num.length; i++) {
for (int j = i + 1; (j > 0) && (num[j] < num[j-1]); j --) {
temp = num[j];
num[j] = num[j-1];
num[j-1] = temp;
}
}
for (int i : num) {
System.out.println(i);
}
}
}
/**
* @ClassName: InsertSort.java
* @Description: 插入排序算法
* @author Bert
* 2014-4-3 下午9:00:03
*/
public class InsertSort {
public static void main(String[] args) {
Integer[] num = {8,9,5,6,7,5,2,5,9,14,2};
if(num == null ){
return;
}
int temp ;
for (int i = 0; i < num.length; i++) {
for (int j = i + 1; (j > 0) && (num[j] < num[j-1]); j --) {
temp = num[j];
num[j] = num[j-1];
num[j-1] = temp;
}
}
for (int i : num) {
System.out.println(i);
}
}
}
0 0
- 排序算法-插入排序
- 排序算法--插入排序
- 排序算法---插入排序
- 排序算法-插入排序
- 排序算法-插入排序
- 排序算法--插入排序
- 排序算法-插入排序
- 排序算法-插入排序
- 排序算法---插入排序
- 排序算法--插入排序
- 排序算法--插入排序
- 排序算法--插入排序
- 排序算法-插入排序
- 排序算法--插入排序
- 排序算法-插入排序
- 排序算法-插入排序
- 排序算法--插入排序
- 排序算法-插入排序
- Find them, Catch them 并查集
- 窗口对象的方法 prompt() 用来输入数据
- java内存管理之二
- 2014开源技术大会(读书汇)
- android的事件处理1(监听 回调 handle)
- 插入排序算法
- javascript弹出框打印某个数值时,弹出NaN?(not a number)
- 论坛营销四要素
- 【DFS&二叉树】Binary Tree Maximum Path Sum
- jvm的参数含义及设置
- fcntl函数说明
- c++ primer阅读笔记-12章-2
- Java内存溢出的详细解决方案
- 【设计模式】设计模式之适配器模式