Java 数组的插入排序

public class InertSortTest {
	public static void main(String[] args) {
		int[] arr = { 88, 17, 68, 64, 56, 96, 11 };
		System.out.println(Arrays.toString(arr));
		for (int i = 1; i < arr.length; i++) {
			int j = i - 1;
			int temp = arr[i];
			while (j >= 0 && arr[j] > temp) {
				arr[j+1]=arr[j];
				j--;
			}
			arr[j+1]=temp;
		}
		System.out.println(Arrays.toString(arr));
	}
}

你可能感兴趣的:(Java,java)