插入排序

2011-03-03  李卓华 

public class InsertSort {

public static void main(String [] args){
int [] a = {1,52,3,21,541,122,321};
for(int i = 1; i < a.length; i++){
for(int j = 0; j < i ; j++){
if ( a[i] < a[j]){
a[i] = a[i] + a[j];
a[j] = a[i] - a[j];
a[i] = a[i] - a[j];
break;
}
}
}
for(int c: a){
System.out.println(c);
}
}
}
268°/2684 人阅读/0 条评论 发表评论

登录 后发表评论