課程
/后端開發(fā)
/Java
/Java入門第一季(IDEA工具)升級版
把代碼怎么改改,能實現(xiàn)輸出數(shù)組中的最大值呢?
2015-08-16
源自:Java入門第一季(IDEA工具)升級版 7-1
正在回答
?//完成 main 方法
? ? public static void main(String[] args) {
? ? ? ??
? ? int[] scores={89,64,91,119,52,73};?
? ? System.out.println("考試成績的前三名為:");
? ??
? ? HelloWorld hello=new HelloWorld();
? ? int max=hello.sort(scores);
? ? System.out.println(max);
? ? }
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public int sort(int[] scores){
? ? ? ? int max1=0;
? ? ? ? for (i=0;i<scores.length;i++){
? ? ? ? ? ? if(max1<scores[i]){
? ? ? ? ? ? ? ? max1=scores[i];
? ? ? ? ? ? }
? ? ? ? } ? ? ? ?
? ? ? ? return max1;?
前三名都得出來怎么搞?
這個方法貌似只能得到第一名
哈哈,謝謝,你的里面也存在一個錯誤哦。for (i=0,)要改為for (int i=0,)....
舉報
0基礎(chǔ)萌新入門第一課,從Java環(huán)境搭建、工具使用、基礎(chǔ)語法開始
3 回答怎么修改,代碼才能成立呢
6 回答我把one的賦值改成了21,怎么還是能輸出ONE是偶數(shù)?
5 回答改錯大神來
3 回答改錯大師來
5 回答以下Java代碼怎么改?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2015-08-17
?//完成 main 方法
? ? public static void main(String[] args) {
? ? ? ??
? ? int[] scores={89,64,91,119,52,73};?
? ? System.out.println("考試成績的前三名為:");
? ??
? ? HelloWorld hello=new HelloWorld();
? ? int max=hello.sort(scores);
? ? System.out.println(max);
? ? }
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public int sort(int[] scores){
? ? ? ? int max1=0;
? ? ? ? for (i=0;i<scores.length;i++){
? ? ? ? ? ? if(max1<scores[i]){
? ? ? ? ? ? ? ? max1=scores[i];
? ? ? ? ? ? }
? ? ? ? } ? ? ? ?
? ? ? ? return max1;?
2015-09-15
前三名都得出來怎么搞?
2015-09-02
這個方法貌似只能得到第一名
2015-08-23
哈哈,謝謝,你的里面也存在一個錯誤哦。for (i=0,)要改為for (int i=0,)....