万分火急,,求救。。 本帖最后由 qiongfengcai 于 2009-09-07 11:37:14 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 for(int i=9;i > 0;i--){ for(int j=1;j <i;j++){ if(dou[j - 1]>dou[j]){ int temp; temp=dou[j - 1]; dou[j - 1] = dou[j]; dou[j] =temp; } } 冒泡每次都是从第一个元素开始的。 可以边读入,边排序的。使用Arrays或Collections的binarySearch确定插入位置 for(int i=0;i <10;i++){ for(int j=i;j <9-i;j++){ if(dou[j]>dou[j+1]){ int temp; temp=dou[j]; dou[j] = dou[j+1]; dou[j+1] =temp; } } 程序应该正确了,每次排序把最大的那个数放到最后面,循环10次,直接写for(int j=i;j <9;j++)也行,注意下数组下标别越界就可以了 java swing 请问用哪个方法可以将StringBuffer反转? 请教关于JDBC的rs.next()的问题 eclipse工程中为什么看不到工程里面的bin目录及bin目录里面的class文件? java操作sql server 2000中的创建表的问题? 如何查找图片并列出 关于equals的问题 请教,如何生成这样的txt文件? 新建web application项时形成的.war文件是做什么的 有一个简单的java程序运行后无结果,run后无结果显示 javac dos下编译源文件大小写敏感问题 java调用dll的问题
for(int i=9;i > 0;i--){ for(int j=1;j <i;j++){ if(dou[j - 1]>dou[j]){
int temp;
temp=dou[j - 1];
dou[j - 1] = dou[j];
dou[j] =temp;
} }
冒泡每次都是从第一个元素开始的。
使用Arrays或Collections的binarySearch确定插入位置
int temp;
temp=dou[j];
dou[j] = dou[j+1];
dou[j+1] =temp;
} } 程序应该正确了,每次排序把最大的那个数放到最后面,循环10次,直接写for(int j=i;j <9;j++)也行,注意下数组下标别越界就可以了