public class Test {
/**
* 插入排序
*
* @param array
*/
public static void insertSort(int[] array) {
int n = array.length;
if (n tmp) {
array[j + 1] = array[j];
} else {
break;
}
}
array[j + 1] = tmp;
System.out.println("第" + i + "次交换后结果," + Arrays.toString(array));
}
}
public static void main(String[] args) {
int[] array = {4, 2, 6, 1, 9, 8, 3, 5, 7};
insertSort(array);
}
}
插入排序java版代码
关注
打赏