public class T20131210 {
public static void main(String[] args) {
int test[] = { 0, 24, 2, 10, 7, 44, 3 };
插入排序(test);
for (int a = 0; a < test.length; a++) {
System.out.println(test[a]);
}
}
public static void 插入排序(int sort[]) {
for (int m = 1; m < sort.length; m++) {
for (int n = 0; n < m; n++) {
int temp;
if (sort[m] < sort[n]) {
temp=sort[m];
for(int o=m;o>n;o--){
sort[o]=sort[o-1];
}
sort[n]=temp;
}
}
}
}
}
//最大操作数=(1+n)*n/2
//所以时间复杂度为O(n^2)
//结果:
//0
//2
//3
//7
//10
//24
//44