public class HelloWorld{ public static void main(String[] args){ int num = 999; int count = 0; if(num>=0&&num<999999999){ while(num!=0){ count++; if (num%=0) else num+=1; System.out.println("它是个"+ count+"位的数!"); break; else{ System.out.println("out"); } } } } }
写的太乱,结构有问题,语法也不准确。按你的意思调整下
if(num>=0&&num<=999999999){ while(num!=0){ num/=10; count++; } System.out.println("它是个"+ count+"位的数!"); }else{ System.out.println("out"); }