问答详情
源自:4-15 编程练习

我错在哪了

public class HelloWorld{

public static void main(String[] args){

int num = 999;

int count = 0;

if(num>=0&&num<=999999999){

    while(num!=0){

        count++;

        num/=10;

    }

    System.out.println("它是个"count+"位的数");

}else{

    System.out.println("输入有误"); 

}

}

}


提问者:慕侠6386488 2018-11-27 14:28

个回答

  • qq_Elaborate_7
    2018-12-07 09:53:26

    public class HelloWorld{

    public static void main(String[] args){

    int num = 999;

    int count = 0;

    for (;num>=0&&num<=999999999;) {

    while (num!=0) {

    count++;

    num/=10;

    }

    System.out.println("它是个"+count+"位的数!");

    break;

    }








    }

    }


  • 即是天堂也是地狱
    2018-12-06 22:53:27

    num/10;不是语句,应该改成num = num/10;

  • 慕码人9302225
    2018-11-27 14:36:00

      System.out.println("它是个"count+"位的数")括号里少个+号 改成

      System.out.println("它是个"+count+"位的数")