最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

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

判斷一個(gè)數(shù)(小于10位)的位數(shù)。 輸入999,則輸出 “它是個(gè)3位的數(shù)!

public class HelloWorld{

public static void main(String[] args){

int num = 999;

int count = 0;

if (num >= 0 ?&& num<=999999999){
while(num != 0){
count++;
num/=10;
}
System.out.println("它是個(gè)"+ count+"位的數(shù)!");
} else{
System.out.println("輸入有誤!");
} ?

上面不是很理解?還有 +count+ 是什么意思

正在回答

6 回答

num/=10;是什么意思啊?


1 回復(fù) 有任何疑惑可以回復(fù)我~
public?class?Test?{????
????final?static?int[]?sizeTable?=?{?9,?99,?999,?9999,?99999,?999999,?9999999,????
????????????99999999,?999999999,?Integer.MAX_VALUE?};????
????static?int?sizeOfInt(int?x)?{????
????????for?(int?i?=?0;;?i++)????
????????????if?(x?<=?sizeTable[i])????
????????????????return?i?+?1;????
????}????
????public?static?void?main(String[]?args)?{????
????????System.out.println(sizeOfInt(1234));????
????????System.out.println(sizeOfInt(123));????
????????System.out.println(sizeOfInt(12345));????
????????System.out.println(sizeOfInt(12));????
????}????
}


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

漢字與count之間是要用+連接才能讓程序正常運(yùn)行

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

if (num >= 0 ?&& num<=999999999){
while(num != 0){
count++;
num/=10;
}

這個(gè)代碼計(jì)算num 的位數(shù)。

System.out.println 代表輸出

輸出:這是一個(gè)3位數(shù)

system.out.println("這是一個(gè)"+count+"位數(shù)“);

雙引號(hào)中是固定的字,+count 就是輸出count 值。

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

波奔兒霸

問(wèn)一下他的計(jì)算過(guò)程是怎么樣,假如num=100哪么他的計(jì)算流程是怎么樣的呢
2016-03-09 回復(fù) 有任何疑惑可以回復(fù)我~

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

? ? int num =999;

? ? int count = 0;

if

(num>=0 && num<=999999999){

while(num!=0){

count++;

num/=10;

}

System.out.println("它是個(gè)"+count+"位的數(shù)");

}else{

System.out.println("輸入有誤");

}

}

}


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

+count+代表輸出count 代表的值

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

舉報(bào)

0/150
提交
取消

判斷一個(gè)數(shù)(小于10位)的位數(shù)。 輸入999,則輸出 “它是個(gè)3位的數(shù)!

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

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

幫助反饋 APP下載

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

公眾號(hào)

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