不太懂..
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(i=1;i<1000000000;i=i*10){
? ? if(num/i>=1){
? ? ? ? count=count+1;
? ? }
? ?
}
System.out.println("它是個"+count+"位數");
}
}
?問題出在那...
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(i=1;i<1000000000;i=i*10){
? ? if(num/i>=1){
? ? ? ? count=count+1;
? ? }
? ?
}
System.out.println("它是個"+count+"位數");
}
}
?問題出在那...
2018-05-29
舉報
2018-05-29
好像除了一開始的i沒給數據類型 沒錯了吧
2018-05-29
int num =999;
int count = 0;
for(long i=1;i<1000000000;i=i*10){
? ? if(num/i>=1){
? ? ? ? count=count+1;? ??
? ? }
}
?System.out.println("它是個"+count+"位的數!");
我自己改好了.
2018-05-29
while (num % 10 != 0) {
count++;
num=num/10;
}
System.out.println("它是個" + count + "位的數!");
2018-05-29
我知道1個問題了 .? long i ; 改了還是有問題