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

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

為什么輸出的結(jié)果不是正確的

import java.util.Arrays;

import java.util.Scanner;

public class j{

public static void main(String args[]){

int[] score= new int[7];

System.out.println("請輸入成績:");

Scanner input=new Scanner(System.in);

int arrys=input.nextInt();

System.out.println("成績的前三名:");

j test=new j();

test.chengji(score);

}

public void chengji(int[] score) {

Arrays.sort(score);

int num=0;

for (int i=score.length-1;i>=0;i--){

if (score[i]<0||score[i]>100){

continue;

}

num++;

if(num>3){

break;

}

System.out.println(score);

}


}}



正在回答

3 回答


import?java.util.Scanner;

public?class?J?{
????public?static?void?main(String?args[])?{
????????int[]?score?=?new?int[7];
????????System.out.println("請輸入成績:");
????????for?(int?i?=?0;?i?<?7;?i++)?{
????????????Scanner?input?=?new?Scanner(System.in);
????????????int?arrys?=?input.nextInt();
????????????score[i]?=?arrys;
????????}
????????System.out.println("成績的前三名:");
????????J?test?=?new?J();
????????test.chengji(score);
????}

????public?void?chengji(int[]?score)?{
????????Arrays.sort(score);
????????int?num?=?0;
????????for?(int?i?=?score.length?-?1;?i?>=?0;?i--)?{
????????????if?(score[i]?<?0?||?score[i]?>?100)?{
????????????????continue;
????????????}
????????????num++;
????????????if?(num?>?3)?{
????????????????break;
????????????}
????????????System.out.println(score[i]);
????????}
????}
}


2 回復(fù) 有任何疑惑可以回復(fù)我~
  1. 類首字母大寫(編程規(guī)范)

  2. int?arrys?=?input.nextInt();可以得到鍵盤獲取的值,獲取后應(yīng)該賦值給數(shù)組的元素
  3. for循環(huán)遍歷數(shù)組數(shù)組時,別忘記角標
1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

公子玖 提問者

謝謝你,大神,你好厲害,???
2019-09-19 回復(fù) 有任何疑惑可以回復(fù)我~

arrays 沒有被用到

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

公子玖 提問者

那怎么修改,求解答,謝謝
2019-09-19 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么輸出的結(jié)果不是正確的

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

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

幫助反饋 APP下載

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

公眾號

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