| 发表于:2007-04-02 15:42:203楼 得分:5 |
是呀,你不要就看他的表达方式,知道原理就行了 // // todo: 在此处添加代码以启动应用程序 // int []box=new int[]{21, 23 ,64, 8 ,12 ,73, 99, 14}; int a; //采用冒泡排序,小到大 for(int i=0;i <box.length-1;i++) { for(int j=0;j <box.length-1-i;j++) { if(box[j]> box[j+1]) { a=box[j]; box[j]=box[j+1]; box[j+1]=a; } } } //output result for(int i=0;i <box.length;i++) { console.writeline((i+1).tostring() + ": "+box[i].tostring()); } | | |
|