public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
int i=1;
for(j=1;j<=10;j++)
{
if((num/i)!=0){
count++;
i*=10;
}
else{
System.out.println("它是个");
System.out.println(count);
System.out.println("位的数!");
break;
}
}
}
}
if((num/i)!=0){ count++; i*=10; } 改成如下: if (num != 0) { count++; num /= 10; }
i*=10;
改成i/10;