慕粉1013107715
2017-03-02 17:08
输入999,则输出 “它是个3位的数!”
HelloWorld.java
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
public class HelloWorld {
public static void main(String[] agr) {
int count = 0;
Scanner scan = new Scanner(System.in);
System.out.println("请输入你要判断的那个数:");
int num = scan.nextInt();
while(num!=0)
{
num=num/10;
count++;
}
System.out.println("你输入的那个数是:"+count+"位数");
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num<=999999999){
if(num>=99999999){
count = 9;
} else if(num>9999999){
count = 8;
} else if(num>999999){
count=7;
} else if(num>99999){
count=6;
} else if(num>9999){
count=5;
} else if(num>999){
count=4;
} else if(num>99){
count=3;
} else if(num>9){
count=2;
}else if(num>0){
count=1;
}
}
System.out.println("它是个"+count+"位的数!");
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题