判斷一個數(shù)(小于10位)的位數(shù),請問為什么提示運行成功,結果錯誤
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 1;
int j=1;
if(num>=0 && num<=999999999){
for(;count<10;count++)
{
? ? j*=10;
? ? if(num/j == 0) break;
}
System.out.println("它是個"+count+"位的數(shù)!");? ?
}
}
}
2018-08-01
中文的感嘆號 !
2018-08-02
public class HelloWorld {
public static void main(String[] args) {
int num = 999;
int count = 1;
int j = 1;
if (num >= 0 && num <= 999999999) {
for (; count < 10; count++) {
j *= 10;
if (num / j == 0)
{
break;
}
}
System.out.println("它是個" + count + "位的數(shù)!");
}
}
}
for循環(huán)里面的if加個大括號 ? 我運行和結果都是正確的 ? 跟感嘆號沒關系?
2018-08-01
System.out.println("它是個"+count+"位的數(shù)!"); ?
感嘆號要用中文符號。