我這個(gè)哪有問題啊,大佬們?
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
?? while (num/10>0){
?????? System.out.println("它是一個(gè)"+count+"位的數(shù)!");
?????? count++;
?? }
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
?? while (num/10>0){
?????? System.out.println("它是一個(gè)"+count+"位的數(shù)!");
?????? count++;
?? }
}
}
2018-07-23
舉報(bào)
2018-07-27
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num>=0 && num<1000000000){
? ? while(num !=0){
? ? ? ? num=num/10;
? ? ? ? count++;
? ? }
}
System.out.println("它是個(gè)"+count+"位的數(shù)!");
?}
}
而且題目要求是小于10位,你沒有把這個(gè)碼上。
2018-07-27
while (num/10>0)? 這個(gè)條件本身就有問題;任何正整數(shù)運(yùn)行這個(gè)表達(dá)式都是true;
應(yīng)該是while(num/10>1)
2018-07-24
2018-07-24
把num放在which循環(huán)語句里面遞除,或者用for語句,必須做到num每次除以10
2018-07-24
死循環(huán)了,num/10始終是大于0的,看樣子你的while后面括號里寫錯(cuò)了
2018-07-24
死循環(huán)了
2018-07-23
想一下num/10>0,當(dāng)num為只有一位的數(shù)的時(shí)候,比如9,9/10=0,于是不執(zhí)行該循環(huán)語句,count還是等于0
2018-07-23
而且這是一個(gè)無限的循環(huán)啊
2018-07-23
應(yīng)該把System.out.println()放在while的外面吧?