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

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

找不到問題,求大神支援

import java.util.Arrays;

public class HelloWorld {

? ??

? ? //完成 main 方法

? ? public static void main(String[] args) {

? ? ? ? int [] h={90,98,89,78,68,0};

? ? ? ? HelloWorld hello=new HelloWorld();

? ? ? ? int []g=hello.getScores(h);

? ? ? ? System.out.println("考試成績的前三名為:");

? ? ? ? for(int d:g){

? ? ? ? ? ? System.out.println(d);

? ? ? ? }

? ? ? ??

? ? }

? ??

? ? //定義方法完成成績排序并輸出前三名的功能

? ? public int[] getScores(int[]a){

? ? ? ? int []b=Arrays.sort(a);

? ? ? ? int []c=new int[3];

? ? ? ? for(int i=0;i<c.length;i++){

? ? ? ? ? ? if(b[i]<100&&b[i]>0)

? ? ? ? ? ? c[i]=b[i];

? ? ? ? ? ? else

? ? ? ? ? ? c[i]=0;

? ? ? ? }

? ? ? ?return c;?

? ? }

}

http://img1.sycdn.imooc.com//577e43060001144d07570567.jpg

正在回答

2 回答

你根本沒按提示做按。。。

package?com.helloworld;
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();
???????hello.max(scores);??
???}
???
???//定義方法完成成績排序并輸出前三名的功能
???public?void?max(int?scores[]){
???????//nums是用來看是否到了3個(gè)
???????int?i,nums=0;
???????//將scores數(shù)組升序排序
???????Arrays.sort(scores);
???????//使用?for?循環(huán)遍歷數(shù)組中的元素,由于要輸出的是前三名成績,所以從后往前遍歷,即倒序遍歷
???????for?(?i?=?scores.length?-?1;?i?>=?0;?i--?)?{?
???????????//如果數(shù)字不符合條件,continue跳過循環(huán)
???????????if(scores[i]<0||scores[i]>100){
???????????????continue;
???????????}
???????????nums=nums+1;
???????????System.out.println(scores[i]);
???????????if(nums>=3){
???????????????break;
???????????}
???????????}
???????
???????
???}

這是我的方法,希望采納。

0 回復(fù) 有任何疑惑可以回復(fù)我~
public?class?HelloWorld?{
????
????//完成?main?方法
????public?static?void?main(String[]?args)?{
????????int[]?scores?=?new?int[]{89,-23,64,91,119,52,73};
????????sortArray(scores);
????}
????
????//定義方法完成成績排序并輸出前三名的功能
????
????public?static?void?sortArray(int[]?arr){
????????int?temp?=?0;
????????for(int?i?=?0?;?i<?arr.length;?i++){
???????????if(arr[i]<0?||?arr[i]?>?100?){
????????????????arr[i]?=?0;
????????????}
????????}
????????for(int?i?=?0?;?i?<?arr.length;i++){
????????????for?(int?j?=?i?+?1?;?j?<?arr.length?;?j++){
????????????????if(arr[i]<arr[j]){
????????????????????temp?=?arr[i];
????????????????????arr[i]?=?arr[j];
????????????????????arr[j]?=?temp;
????????????????}
????????????}
????????}
????????for(int?i?=?0?;?i<?arr.length;?i++){
????????????if(i?<?3?)
????????????????System.out.println(arr[i]);
????????}
????}
}

這是我寫的答案,可能有點(diǎn)小麻煩吧,你可以看一下。如果不是因?yàn)椴恢涝趺磳?,而是因?yàn)椴恢滥愕臑槭裁磿?huì)出現(xiàn)問題的話,可以私聊我,我?guī)湍憬忉屢幌隆?/p>

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

舉報(bào)

0/150
提交
取消
Java入門第一季(IDEA工具)升級(jí)版
  • 參與學(xué)習(xí)       1167340    人
  • 解答問題       18589    個(gè)

0基礎(chǔ)萌新入門第一課,從Java環(huán)境搭建、工具使用、基礎(chǔ)語法開始

進(jìn)入課程

找不到問題,求大神支援

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

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

幫助反饋 APP下載

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

公眾號(hào)

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