public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(count=1;count<10;count++){
num=num/10;
if(num==0){
break;
}
}
System.out.println("它是个"+count+"位的数!");
}
}
两个都不能提交,大神在哪了
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num<1000000000&&num>0){
for(count=1;count<10;count++){
num=num/10;
if(num==0){
break;
}
}
System.out.println("它是个"+count+"位的数!");
}else{
System.out.println("超出范围");
}
}
}