 
		Y_14
2021-11-25 14:05
if (num >= 0  && num<=999999999){
while(num != 0){
count++;
num/=10;
}
System.out.println("它是个"+ count+"位的数!");
} else{
System.out.println("输入有误!");
}
这样写输入0不就是为0位数了?
 
				输入0的话,我看输出是"输入有误!"吧
 
				这样写count初始化得从1开始,即int count = 1;
或者用do...while循环
Java入门第一季(IDEA工具)
1168088 学习 · 18754 问题
相似问题