标签:print 数组 bsp 个数 ring ++ void int static
直接排序是将末排序的数据插入至已排好序序列的合适位置。
具体流程如下:
代码:
public static void insorttow(){
int a[] = {25,11,45,26,12,78};
int tmp = 0;
for(int i=1;i<a.length;i++){
tmp = a[i];
int j = i-1;
for(;j>=0;j--){
if(a[j]>tmp){
a[j+1]=a[j];
}else{
break;
}
}
a[j+1] = tmp;
System.out.println(i + ":" + Arrays.toString(a));
}
}
标签:print 数组 bsp 个数 ring ++ void int static
原文地址:http://www.cnblogs.com/hexns/p/7461311.html