請(qǐng)問(wèn)哪里出現(xiàn)問(wèn)題了·····
import java.util.Arrays;
public class HelloWorld {
???
??? //完成 main 方法
??? public static void main(String[] args) {
????? int[] scores={89,-23,64,91,119,52,73};
????? HelloWorld hello=new HelloWorld();
????? hello.threeHigh(scores);
?????
??? }
???
??? //定義方法完成成績(jī)排序并輸出前三名的功能
??? public void threeHigh(int[] scores){
???????
??????? Arrays.sort(scores);
??????? int count=0;
??????? for(int i=scores.length-1;i>=0;i--){
??????????? if(scores[i]<0 || scores[i]>100 ) {? continue;? }
??????????
??????????????? count++;
????????
???????????
??????????? if(count>=2){
??????????????? break;
??????????? }
??????????? System.out.println(scores[i]);}
??????? }
??? }
???
???
2016-04-10
if(count>=2)這句,當(dāng)count=1,條件為假,執(zhí)行輸出打印91,然后循環(huán),count=2,條件為真,執(zhí)行break,程序結(jié)束.沒(méi)有機(jī)會(huì)執(zhí)行輸出打印了.
2016-04-06
是照著老師給的代碼做的,還是運(yùn)行不出來(lái),試了下其他同學(xué)的代碼也沒(méi)有運(yùn)行出來(lái)···
2016-04-06
count 應(yīng)該是>3,才跳出循環(huán)
2016-04-05
覺(jué)得最好應(yīng)該是排序好自后向前輸出不大于100的項(xiàng),同時(shí)下標(biāo)前移,設(shè)置計(jì)數(shù)器,這樣沒(méi)什么問(wèn)題吧.....
2016-04-04
你的main方法里面沒(méi)有輸出
2016-04-04
同學(xué)你得先按大小排序然后再刪除不合格的成績(jī)