public class InsetSort {
public static void main(String[] args){
int[] array = {34, 8, 64, 51, 32, 21};
insertSort(array);
}
public static void insertSort(int[] array){
int temp = 0;
for(int i = 1; i < array.length; i++){
for(int j = i; j > 0; j--){
if(array[j] < array[j - 1]){
temp = array[j - 1];
array[j - 1] = array[j];
array[j] = temp;
}else{
break;
}
}
}
for(int i = 0; i < array.length; i++){
System.out.print(array[i] + " ");
}
}
}
07-24
59万+
09-05
2086