package one;import java.util.Arrays;public class one {??? ??? //完成 main 方法??? public static void main(String[] args) {??????? ?????? one hello=new one();?????? ??????? int[] scores={89 , -23 , 64 , 91 , 119 , 52 , 73};??????? ??????? int[] three=hello.change(scores);???????????????????????????????????????????????? //wrong??????????????? System.out.println(three);??????? ??? }??? ??? //定義方法完成成績(jī)排序并輸出前三名的功能??? public? int change(int[] scores){??????? ??????? Arrays.sort(scores);??????? ??????? int[] one=new int[3];??????? ??????? for(int i = 0 ; i < 3 ; i++){??????????? ??????????? if(scores[i] > 0 && scores[i] < 100){??????????? ??????????? int m=0;??????????? ?????????????? one[m]=scores[i];??????????????? ??????????????? m++;??????????? }??????? ??????? return one;??????????????????????????????????????????????????????????????????????????????? ?//wrong??????? ??????? }??? }??????? }
1 回答
已采納

慕萊塢9220042
TA貢獻(xiàn)377條經(jīng)驗(yàn) 獲得超508個(gè)贊
你好,
package?one; import?java.util.Arrays; public?class?one?{ ???? ????//完成?main?方法 ????public?static?void?main(String[]?args)?{ ???????? ???????one?hello=new?one(); ??????? ????????int[]?scores={89?,?-23?,?64?,?91?,?119?,?52?,?73}; ???????? ????????int[]?three=hello.change(scores);?????????????????????????????????????????????????//wrong ????????for?(int?i?=?0;?i?<?three.length;?i++)?{ ???????? System.out.println(three[i]+","); } ????????System.out.println(three);???????? ????} ???? ????//定義方法完成成績(jī)排序并輸出前三名的功能 ????public??int[]?change(int[]?scores){ ???????? ????????Arrays.sort(scores); ???????? ????????int[]?one=new?int[3]; ???????? ????????for(int?i?=?0?;?i?<?3?;?i++){ ???????????? ????????????if(scores[i]?>?0?&&?scores[i]?<?100){ ???????????? ????????????int?m=0; ???????????? ???????????????one[m]=scores[i]; ???????????????? ????????????????m++; ????????????} ???????? ????????} ????????return?one;????????????????????????????????????????????????????????????????????????//wrong ????} ???????? }
試下這個(gè),可以正常運(yùn)行,具體輸出好像有問題,自己查下代碼看下哪里不對(duì);
望樓主采納!
添加回答
舉報(bào)
0/150
提交
取消