`

排序算法之插入排序

    博客分类:
  • java
阅读更多
package com.xiaojin;

public class InsertSort {
static int array[]={1,3,2,7,4,5,8,6,9,10};
public static void main(String args[]){
for(int i=1;i<10;i++){

for(int j=i;j>0;j--){
if(array[j]<array[j-1]){
int t=array[j-1];
array[j-1]=array[j];
array[j]=t;
}
}
}
for(int i=0;i<10;i++)
System.out.println(array[i]);
}
}


输出为
1
2
3
4
5
6
7
8
9
10
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics