public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(int i=0;i<10;i++){
num/=10;
count++;
if(num<1)
break;
}
System.out.println("它是个"+count+"位的数!");
}
}
代码没有问题呀
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if((num/1)<10)
{
System.out.println("1位数");
}
if((num/10)<10 && (num/1)>10)
{
System.out.println("1位数");
}
if((num/100)<10 && (num/10)>10)
{
System.out.println("它是个3位的数!");
}
}
}
if 好像不能用break吧