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

為了賬號安全,請及時綁定郵箱和手機立即綁定

請問大神我的代碼哪里錯啦

public class HelloWord {

import java.util.Arrays;

? ?//完成 main 方法

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

? ?int[] scores=new int[]{89,-23,64,91,119,52,73};

? ? ? ?int count=0;

? ? ? ?HelloWord gen=new HelloWord();

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

? ? ? ?gen.oo(scores);? ??

? ?}

? ?

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

? ?

? ?public void oo(int[] scores){

? ? ? ?Arrays.sort(scores);

? ? ? ?for(int i=scores.length;i>=0;i--){

? ? ? ? ? if(scores>0&&scores<100) {

? ? ? ? ? ?count++;

? ? ? ? ? }

? ? ? ? else if(count=3){? ? ? ?

? ? ? ? ? ?System.out.println(Arrays.toString(scores));? ? }

? ? ? ? ? else{continue;}

? ? ? ? ??

? ? ? ? ? ?? ? ? ? ?

? ? ? ?}

? ?}

? ?

? ?

? ?

? ?

? ?

? ?

? ?

? ?

}


正在回答

2 回答

import java.util.Arrays;

public class hello{


? ?//完成 main 方法

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

? ?int[] scores=new int[]{89,-23,64,91,119,52,73};

? ? ? ?hello gen=new hello();

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

? ? ? ?gen.oo(scores); ? ?

? ?}

? ?

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

? ?

? ?public void oo(int[] scores){

? int count=0;

? ? ? ?Arrays.sort(scores);

? ? ? ?for(int i=scores.length-1;i>=0;i--)

? ? ? ?{

? ? ? ? ? if(scores[i]<0||scores[i]>100)?

? ? ? ? ? {

? ? ? ? ?continue;

? ? ? ? ? }

? ? ? ? ? count++;

? ? ? ?if(count<=3)

? ? ? ? { ? ? ??

? ? ? ? ? ?System.out.println(scores[i]); ?

? ? ? ? } ? ? ? ? ??

? ? ? ?}

? ?}


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

慕圣4085380

scores[i]<0||scores[i]>100 這行代碼有問題吧 應(yīng)該是 0-100才有效 這行代碼里面 只要滿足一條 就繼續(xù)了 應(yīng)該是 scores[i]<0&&scores[i]>100 吧
2018-06-15 回復(fù) 有任何疑惑可以回復(fù)我~
  1. 首先?int?count=0?要在方法內(nèi)部定義。

  2. ? 根據(jù)數(shù)組的語法,數(shù)組最后一位是它的長度-1,這里是for(int i=scores.length-1;i>=0;i--)

  3. ?count ++;? 條件應(yīng)該在?下面if判斷里

  4. ? if(scores>0&&scores<100)?這里語法錯誤,? scores?是數(shù)組,而你for循環(huán)的是scores?里的每個元素?所以應(yīng)該是scores[i].

  5. 這里輸出的應(yīng)該是? System.out.println(scores[i])?而且?應(yīng)該在第一個 if?判斷內(nèi)

  6. 第二if?不需要else ,而且判斷條件應(yīng)該是 ==,而不是= 。

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

舉報

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

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

進(jìn)入課程

請問大神我的代碼哪里錯啦

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

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

幫助反饋 APP下載

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

公眾號

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