課程
/后端開發(fā)
/Java
/Java入門第一季(IDEA工具)升級版
拜托了
2017-05-23
源自:Java入門第一季(IDEA工具)升級版 7-1
正在回答
import java.util.Arrays;
??
public class HelloWorld {
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello = new HelloWorld();
? ? ? ? int[] scores = new int[]{89,-23,64,91,119,52,73};
? ? ? ? hello.sort(scores);
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void sort(int[] scores){
? ? ? ? Arrays.sort(scores);
? ? ? ? int count =0;
? ? ? ? System.out.println("考試成績的前三名為:");
? ? ? ? for(int i=scores.length-1; i>=0;i--){
? ? ?
? ? ? ? ? ? if(scores[i] <100 && scores[i] > 0){
? ? ? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? ? ? ? ? count ++;
? ? ? ? ? ? }
? ? ? ? ? ? if(count == 3){
? ? ? ? ? ? ? ? break;
? ? ? ? }
}
牧勤奮 提問者
餓,我忘說了這個有參有返回值的
public void nmb(int[] a){ ? ? ? ?Arrays.sort(a); ? ? ?int count = 0; ? ? ?System.out.println("考試成績的前三名為:"); ? ? ?for(int i = a.length - 1; i >= 0; i--){ ? ? ? ? ?if((a[i]<0)|| (a[i]>100)) continue; ? ? ? ? ?System.out.println(a[i]); ? ? ? ? ?count++; ? ? ? ? ?if(count == 3) break;}}
舉報
0基礎(chǔ)萌新入門第一課,從Java環(huán)境搭建、工具使用、基礎(chǔ)語法開始
1 回答能給個正確答案參考一下嗎
1 回答正確答案
5 回答求正確答案
2 回答未顯示正確答案,學(xué)友們有沒有這樣的情況?
1 回答正確答案就是這個
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-05-23
import java.util.Arrays;
??
public class HelloWorld {
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello = new HelloWorld();
? ? ? ? int[] scores = new int[]{89,-23,64,91,119,52,73};
? ? ? ? hello.sort(scores);
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void sort(int[] scores){
? ? ? ? Arrays.sort(scores);
? ? ? ? int count =0;
? ? ? ? System.out.println("考試成績的前三名為:");
? ? ? ? for(int i=scores.length-1; i>=0;i--){
? ? ?
? ? ? ? ? ? if(scores[i] <100 && scores[i] > 0){
? ? ? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? ? ? ? ? count ++;
? ? ? ? ? ? }
? ? ? ? ? ? if(count == 3){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ??
? ??
? ??
}
2017-05-23
餓,我忘說了這個有參有返回值的
2017-05-23
public void nmb(int[] a){
? ? ? ?Arrays.sort(a);
? ? ?int count = 0;
? ? ?System.out.println("考試成績的前三名為:");
? ? ?for(int i = a.length - 1; i >= 0; i--){
? ? ? ? ?if((a[i]<0)|| (a[i]>100)) continue;
? ? ? ? ?System.out.println(a[i]);
? ? ? ? ?count++;
? ? ? ? ?if(count == 3) break;
}
}