插入排序:
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)); }
原文:http://www.cnblogs.com/umao/p/3940536.html