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

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

這個(gè)程序可以正確執(zhí)行嗎?

import java.util.Arrays;

import java.util.Scanner;


public class HelloWorld {

? ??

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

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

?

? ? ? ?//定義一個(gè)數(shù)組,并從鍵盤輸入數(shù)據(jù)。

? ? ? ?int[] scores;

? ? ? ? for (int i=1;i<=9;i++){

? ? ? ? ? ? Scanner input=new Scanner(System.in);

? ? ? ? ? ? int nums= input.nextInt(); ?

? ? ? ? ? ? scores[i] = nums;

? ? ? ? }


? ? ? ? System.out.println("考試前三名成績?yōu)椋?);

? ? ? ? HelloWorld topthree=new HelloWorld(); ? ?

? ? ? ? topthree.three(scores);

? ? }

? ??

? ? //百分試卷完成成績排序并輸出前三名的功能

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

? ? ? ? Arrays.sort(scores);

? ? ? ? int num=0;

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

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

? ? ? ? ? ? ? ? continue; ??

? ? ? ? ? ? } ? ? ? ? ? ?

? ? ? ? ? ? num++;

? ? ? ? ? ? if (num>3){

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? }

? ? ? ? System.out.println("第"+num+"名是:"+scores[i]); ??

? ? ? ? }

? ? }

}




正在回答

1 回答

import java.util.Arrays;

import java.util.Scanner;


public class HelloWorld {

? ??

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

? ? ? ??

?

? ? ? ?//定義一個(gè)數(shù)組,并從鍵盤輸入數(shù)據(jù)。

? ? ? ?int[] scores = new int[9];//這里你應(yīng)該定義數(shù)組的長度不然會報(bào)錯(cuò)

? ? ? ? for (int i=1;i<=9;i++){

? ? ? ? System.out.println("請輸入考試成績:");//錄入成績的提示代碼我們應(yīng)該放在循環(huán)內(nèi),不然什么都沒有不利于我們錄入信息

? ? ? ? ? ? Scanner input=new Scanner(System.in);

? ? ? ? ? ? int nums= input.nextInt(); ?

? ? ? ? ? ? scores[i-1] = nums;//如果你要i從1開始,scores[i-1]這里就應(yīng)該設(shè)為i-1因?yàn)閿?shù)組下標(biāo)從0開始

? ? ? ? }


? ? ? ? System.out.println("考試前三名成績?yōu)椋?);

? ? ? ? HelloWorld topthree=new HelloWorld(); ? ?

? ? ? ? topthree.three(scores);

? ? }

? ??

? ? //百分試卷完成成績排序并輸出前三名的功能

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

? ? ? ? Arrays.sort(scores);

? ? ? ? int num=0;

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

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

? ? ? ? ? ? ? ? continue; ??

? ? ? ? ? ? } ? ? ? ? ? ?

? ? ? ? ? ? num++;

? ? ? ? ? ? if (num>3){

? ? ? ? ? ? ? ? break;

? ? ? ? ? ? }

? ? ? ? System.out.println("第"+num+"名是:"+scores[i]); ??

? ? ? ? }

? ? }

}

程序基本沒什么問題,上面有我對你存在問題的說明和建議。

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

舉報(bào)

0/150
提交
取消

這個(gè)程序可以正確執(zhí)行嗎?

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

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

幫助反饋 APP下載

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

公眾號

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