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

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

為啥那么啊啊

為什么這樣不行

package pratice;

import java.util.*;

public class 返回成績 {

? ? //完成 main 方法

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

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

? ? ? ? ? ? ? ? ? ? ? 返回成績 hw=new 返回成績();

? ? ? ? hw.sort(scores);

??

? ? }?

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

? ? public void sort(int[] scores)

? ? { int count=0;

? ? ? ? Arrays.sort(scores);

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

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

? ? ? ? {

? ? ? ? ? ?{

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

? ? ? ? ? ? continue;

? ? ? ? ? ?}

? ? ? ? count++;

? ? ? ?while(count==3)

? ? ? ? break;

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

? ? ? ? }

? ? } ??

}

為什么這樣不行

正在回答

3 回答

感覺就是寫的太粗心了 可以從第一行開始仔細(xì)檢查檢查,這樣記憶也比較深刻

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

張晨風(fēng) 提問者

非常感謝!
2016-11-30 回復(fù) 有任何疑惑可以回復(fù)我~
#2

張晨風(fēng) 提問者

恩恩,謝謝,以后一起好好學(xué)習(xí)
2016-11-30 回復(fù) 有任何疑惑可以回復(fù)我~
/*把你的循環(huán)語句?while(count==3)?改成條件語句?if(count>3)?就可以了
你代碼寫的太不規(guī)范了,看得都累
盡量不要寫中文??注意格式
*/
import?java.util.Arrays;

public?class?Demo3?{
	//?完成?main?方法
	public?static?void?main(String[]?args)?{
		int[]?scores?=?new?int[]?{?89,?-23,?64,?91,?119,?52,?73?};
		Demo3?hw?=?new?Demo3();
		hw.sort(scores);

	}

	//?定義方法完成成績排序并輸出前三名的功能
	public?void?sort(int[]?scores)?{
		int?count?=?0;
		Arrays.sort(scores);
		System.out.println("考試成績的前三名為:");
		for?(int?i?=?scores.length?-?1;?i?>=?0;?i--)?{

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

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


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

張晨風(fēng) 提問者

>3與==3的區(qū)別在哪呢
2016-12-01 回復(fù) 有任何疑惑可以回復(fù)我~
#2

mk_mjh 回復(fù) 張晨風(fēng) 提問者

>3就是說count數(shù)值大于3都會跳出. 但是==3意思是count只有在等于3的時候會跳出,count等于4了又開始打印. 題目要求我們只打印前3個數(shù),所以應(yīng)該用>3.
2017-01-15 回復(fù) 有任何疑惑可以回復(fù)我~

/*把你的循環(huán)語句 while(count==3) 改成條件語句 if(count>3) 就可以了

你代碼寫的太不規(guī)范了,看得都累

盡量不要寫中文 ?注意格式

*/

import java.util.Arrays;


public class Demo3 {

// 完成 main 方法

public static void main(String[] args) {

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

Demo3 hw = new Demo3();

hw.sort(scores);


}


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

public void sort(int[] scores) {

int count = 0;

Arrays.sort(scores);

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

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


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

continue;

}


count++;

if (count > 3) {

break;

}

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

}

}

}


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

舉報(bào)

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

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

進(jìn)入課程

為啥那么啊啊

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

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

幫助反饋 APP下載

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

公眾號

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