package com.paixu;
//直接插入排序
public class SISort {
public int[] sisort(int[] src){
int l;
for(int i=1;i<src.length;i++){
int j=i-1;
l = src[i];
while((j>=0)&&(l<src[j])){
src[j+1] = src[j];
j--;
}
src[j+1] = l;
}
return src;
}
public static void main(String[] args) {
int[] src = {49,38,65,97,76,13,27,49};
int[] src1 = new SISort().sisort(src);
for(int i=0;i<src1.length;i++){
System.out.print(src1[i]+" ");
}
}
}
//直接插入排序
public class SISort {
public int[] sisort(int[] src){
int l;
for(int i=1;i<src.length;i++){
int j=i-1;
l = src[i];
while((j>=0)&&(l<src[j])){
src[j+1] = src[j];
j--;
}
src[j+1] = l;
}
return src;
}
public static void main(String[] args) {
int[] src = {49,38,65,97,76,13,27,49};
int[] src1 = new SISort().sisort(src);
for(int i=0;i<src1.length;i++){
System.out.print(src1[i]+" ");
}
}
}