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

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

怎樣輸入數(shù)組?

?for (int i=0;i<5;i++)
?{
??double scores[i]=input.nextDouble();
?}

包也導(dǎo)入了,也創(chuàng)建了input對象,循環(huán)里的這一句報錯了,要手動輸入成績怎么辦呢?有什么好的輸入方法?

正在回答

2 回答

Scanner?input?=?new?Scanner(System.in);
double[]?scores?=?new?double[5];
for(int?i?=?0;i<5?;?i++){
scores?=?input.nextDouble();
}


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

cs_大白 提問者

我修改后還是報錯... public static void main(System[] args) { System.out.println("請輸入五個學(xué)生成績:"); Scanner input=new Scanner(System.in); double[] scores=new double[5]; for (int i=0;i<5;i++) { scores=input.nextDouble(); } System.out.println("學(xué)生成績打印為:"); System.out.println(Arrays.toString(scores)); }
2015-05-18 回復(fù) 有任何疑惑可以回復(fù)我~
#2

cs_大白 提問者

我知道了... 手殘打錯了,謝謝!(∩_∩)
2015-05-19 回復(fù) 有任何疑惑可以回復(fù)我~

正確代碼:

public static void main(String[] args)
{
?System.out.println("請輸入五個學(xué)生成績:");
?Scanner input=new Scanner(System.in);
?double []scores=new double[5];
?for (int i=0;i<5;i++)
?{
??scores[i]=input.nextDouble();
?}
?System.out.println("學(xué)生成績打印為:");
?System.out.println(Arrays.toString(scores));
}?

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

舉報

0/150
提交
取消

怎樣輸入數(shù)組?

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

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

幫助反饋 APP下載

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

公眾號

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