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