第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

初學(xué),看不出來(lái)出錯(cuò)點(diǎn),請(qǐng)高手幫嗎。

package?imooc;
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();????
????int[]?good=hello.top3(scores);
????}
????//定義方法完成成績(jī)排序并輸出前三名的功能
????pubic?int[]?top3(int[]??scores){
???????Arrays.sort(scores);
???????int[]?good=new?int?[3];
???????for(int?i=scores.length-1;i>scores.length-3;i--){
????	???if?(scores[i]<100);
????	???????if(scores[i]>0);
????	???????else?continue;
????	???int?j=0;
????	???good[j]=scores[i];
????	???j++;
????	???System.out.println(good[j]);
????	???
???????}
???????return?good;?	
????}
}


正在回答

4 回答

http://img1.sycdn.imooc.com//57392d500001ca9705410659.jpg


import java.util.Arrays;

public class HelloWorld {
???? ?
?????? //完成 main 方法
??? public static void main(String[] args) {
??????? int[] scores ={89,-23,64,91,119,52,73};
??????? System.out.println("考試成績(jī)的前三名為:");
??????? HelloWorld hello = new HelloWorld();
??????? hello.showTop(scores);
??? }
?? ?
??? public void showTop(int[] scores){
??????? // 定義方法完成成績(jī)排序并輸出前三名的功能
??????? Arrays.sort(scores);
??????? int sum = 0 ;
??????? for(int i = scores.length - 1 ; i >= 0 ; i --){
??????????? if(scores[i] < 0 || scores[i] > 100){
????????????? ?
?????????????? continue;
??????????? }
?????????? ?
?????????????? sum ++ ;
?????????? ?
??????????? if( sum > 3 ){
?????????????? ?
??????????????? break;
?????????????? ?
??????????? }
?????????? ?
??????????? System.out.println(scores[i]);
?????????? ?
??????? }
??? }
}

0 回復(fù) 有任何疑惑可以回復(fù)我~

package com.doe;

import java.util.Arrays;


public class Hello {

?? ?public static void main(String[] args) {
?? ??? ?int[] scores={89,-23,64,91,119,52,73};
?? ??? ?Hello hello=new Hello();
?? ??? ?String info=hello.show(scores);
?? ?? ??? ?System.out.println(info);
?? ?}
?? ??? ?public String show(int[] scores){
?? ?????? ?
?? ???????? Arrays.sort(scores);
?? ??????? ?
?? ???????? return "第一名是"+scores[scores.length-1]+"第二名是"+scores[scores.length-2]+"第三名是"+scores

?? ?[scores.length-3];
?? ???? }

}
最簡(jiǎn)單方法,考慮下這種方法

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕函數(shù)9049899

你的方法,是建立在已經(jīng)知道成績(jī)數(shù)組的前提下,原始成績(jī)數(shù)組是6個(gè)元素,其中-23和119是無(wú)效的,還剩下4個(gè)有效元素,足夠題目要求的前三名成績(jī)了。但是,問(wèn)題來(lái)了,假如原始成績(jī)數(shù)據(jù)是需要用戶(hù)輸入的input.nextInt(),或者未知的,滿(mǎn)足不了至少需要三個(gè)有效成績(jī)的要求,你的程序就有問(wèn)題叻。這就是為什么要判斷有效數(shù)字count的原因了。
2016-05-28 回復(fù) 有任何疑惑可以回復(fù)我~
#2

熙希君 回復(fù) 慕函數(shù)9049899

說(shuō)的甚理,謝謝,是我思維方式簡(jiǎn)單了
2016-06-02 回復(fù) 有任何疑惑可以回復(fù)我~

12行public ?還有為什么不輸出可能是你If else哪里的語(yǔ)法問(wèn)題

0 回復(fù) 有任何疑惑可以回復(fù)我~
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();
?????????int?count?=hello.sort(scores);
?????????System.out.println("前三名的數(shù)量為:"+count);
????}
????//定義方法完成成績(jī)排序并輸出前三名的功能
????public?int?sort(int[]?scores){
????????int?count=0;
????????Arrays.sort(scores);
????????for(int?i=scores.length-1;i>=0;i--){
????????????if(count==3){
????????????????break;
????????????}
????????????if(scores[i]<=100&&scores[i]>=0){
????????????????System.out.println(scores[i]);
????????????????count++;
????????????}
????????????else
????????????????continue;
????????}
????????return?count;
????}???
}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

初學(xué),看不出來(lái)出錯(cuò)點(diǎn),請(qǐng)高手幫嗎。

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)