課程
/后端開發
/Java
/Java入門第一季(IDEA工具)升級版
就是成績用Scanner輸入的
2016-12-11
源自:Java入門第一季(IDEA工具)升級版 7-1
正在回答
無法解析的時候可以看看是不是少了大括號什么的
import?java.util.*; public?class?HelloWorld?{ ???? ????//完成?main?方法 ????public?static?void?main(String[]?args)?{ ????????Scanner?sc?=?new?Scanner(System.in); ????????//?ArrayList<Integer>?input?=?new?ArrayList<>(); ????????System.out.println("How?many?scores:?"); ????????if?(sc.hasNextInt()){ ????????????int?number?=?sc.nextInt(); ????????????int[]?inputScore?=?new?int[number]; ????????????for?(int?i?=?0;?i?<?number;?i?++){ ????????????????System.out.println("Input?score:"); ????????????????inputScore[i]?=?sc.nextInt(); ????????????} ????????} ????????top3(inputScore); ????????//?while?(sc.hasNextInt()){ ????????//?????input.add(sc.nextInt()); ????????//?} ???????? ????????//?int[]?scores?=?new?int[]{89?,?-23?,?64?,?91?,?119?,?52?,?73}; ????????//?top3(scores); ???????? ???????? ????} ???? ????//定義方法完成成績排序并輸出前三名的功能 ????public?static?int[]?top3(int[]?scores){ ????????int[]?result?=?new?int[3]; ????????int?count?=?0; ????????Arrays.sort(scores); ????????for?(int?i?=?scores.length?-?1;?count?<?3?&&?i?>=?0;?i?--){ ????????????if?(scores[i]?>=?0?&&?scores[i]?<=?100){ ????????????????result[count++]?=?scores[i]; ????????????} ????????} ????????System.out.println(Arrays.toString(result)); ????????return?result; ????}
清晨得曙光 提問者
舉報
0基礎萌新入門第一課,從Java環境搭建、工具使用、基礎語法開始
1 回答為什么不輸出成績,只輸出上面的考試成績前三名。
3 回答第四行括號里不用score,直接輸入考試成績68怎樣
8 回答如何實現控制輸入的成績在0~100中間?
1 回答更改題中的特定考試成績為鍵盤輸入
2 回答怎么優化使得成績可以由用戶輸入啊,代碼怎么寫的
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-12-13
無法解析的時候可以看看是不是少了大括號什么的
2016-12-12