插入排序——Java

package com.hj.sort;

import java.util.Arrays;

public class InsertionSort {
	
	public static void main(String[] args) {
		int[] array = {44, 23, 25, 65, 1, 3, 2, 16};
		
		insertionSort(array);
		System.out.print(Arrays.toString(array));
		
	}
	
	public static void insertionSort(int[] array){
		for(int i = 1; i < array.length; i++) {
                        //保存待插入的数据
			int temp = array[i];
			int j;
			for(j = i - 1; j>=0 && temp

 

你可能感兴趣的:(Java基础)