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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么這個num一直報錯

為什么這個num一直報錯

ThreeAgain 2017-06-28 17:50:57
import java.util.Arrays ;public class HelloWorld {? ? //完成 main 方法? ? public static void main(String[] args) {? ? ? ?? ? ? ? int[] scores = {89,-23,64,91,119,52,73};//數(shù)組? ? ? ? System.out.println("前三名的成績:");//輸出? ? ? ? HelloWorld ?hello = new ?HelloWorld() ; //建對象? ? ? ? hello.three(scores);//調(diào)用方法,傳入數(shù)組? ?? ? }? ??? ? //定義方法完成成績排序并輸出前三名的功能? ? ? ?public void three (int[] scores){? ? ? ? ? ?Arrays.sort(scores);//排序? ? ? ? ? ?int num = 0; //保存有效成績的數(shù)量? ? ? ? ? ?for(int i = scores.length-1;i>=0; i--){? ? ? ? ? ? ? ?if(scores[i]<0||scores[i]>100);{? ? ? ? ? ? ? ?continue;? ? ? ? ? ? ? ?num++;? ? ? ? ? ?? ? ? ? ? ?? ? ? ? ? ? ? ?if(num>3){? ? ? ? ? ? ? ? ? ?break;? ? ? ? ? ?}? ? ? ? ? ?System.out.println(scores[i]);? ? ? ?}? ? ? ? ? ?}? ? ? ?? ? }? ? ?? ??}
查看完整描述

3 回答

已采納
?
望遠

TA貢獻1017條經(jīng)驗 獲得超1032個贊

import?java.util.Arrays?;
public?class?HelloWorld?{

	//完成?main?方法
	public?static?void?main(String[]?args)?{

		int[]?scores?=?{89,-23,64,91,119,52,73};//數(shù)組
		System.out.println("前三名的成績:");//輸出
		HelloWorld??hello?=?new??HelloWorld()?;?//建對象
		hello.three(scores);//調(diào)用方法,傳入數(shù)組

	}

	//定義方法完成成績排序并輸出前三名的功能
	public?void?three?(int[]?scores){
		Arrays.sort(scores);//排序
		int?num?=?0;?//保存有效成績的數(shù)量
		for(int?i?=?scores.length-1;i>=0;?i--){
			if(scores[i]<0||scores[i]>100){//這里沒有;
				continue;//continue后面的代碼無法得到執(zhí)行,而報錯。
			}//你應(yīng)該是想這樣寫,輸出成績前三名,注意花括號的位置
			num++;


			if(num>3){
				break;
			}
			System.out.println(scores[i]);
		}

	}


}


查看完整回答
1 反對 回復(fù) 2017-06-28
?
蜂之谷

TA貢獻564條經(jīng)驗 獲得超863個贊

continue 后不能再寫其它代碼了

查看完整回答
反對 回復(fù) 2017-06-28
  • 3 回答
  • 0 關(guān)注
  • 1587 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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