首页 > 代码库 > java 常用算法

java 常用算法

插入排序:

public static void main(String[] args) {		int array[] = {5,4,2,45,44,34,22};		System.out.println(Arrays.toString(array));		for (int i = 0; i < array.length; i++) {			int tempMin = array[i];			for (int j = i+1; j < array.length; j++) {				if(array[j]<tempMin){					int t = array[i];					array[i] = array[j];					array[j] = t;				}			}		}		System.out.println(Arrays.toString(array));	}

  

java 常用算法