public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num>=0 && num<=9999999999){
while(num!=0){
count++;
num/=10;
System.out.println("他是个"+count+"位数");
}else{
System.out.println("重新输入");
}
}
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num>=0 && num<=999){
while(num!=0){
count++;
num/=10;
} System.out.println("他是个"+count+"位数");//输出放在while循环执行完毕之后
}//else是与if来嵌套的
else{
System.out.println("重新输入");
}
}
}
(额。。。应该是这样 加油呐~慢慢来 一定要细心呦)
最明显的9999999999超出int范围 还有if......else语法使用错误 括号不能乱打
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num>=0 && num<=9999999999){
while(num!=0){
num/=10;
count++;
System.out.println("他是个"+count+"位数");
}else{
System.out.println("重新输入");
}
}
}
}