下面這個代碼為啥結果是0位數?
?public class hello { ? ?
public static void main(String[] args) { ? ? ? ?
int count = 0; ? ?
?for(int num = 9; (num/=10)>0 ;){ ? ?
?count++; ? ?
?} ? ?
?System.out.println("它是個"+count+"位數");
?}
?}
?public class hello { ? ?
public static void main(String[] args) { ? ? ? ?
int count = 0; ? ?
?for(int num = 9; (num/=10)>0 ;){ ? ?
?count++; ? ?
?} ? ?
?System.out.println("它是個"+count+"位數");
?}
?}
2017-08-01
舉報
2017-08-01
for循環中的循環條件不通過,count仍為初值0,所以是0位數