qq_沐曦_2
2016-02-27 11:23
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num>=100&&num<=999)
{
System.out.println("它是个3位的数");
}else if (num>=10&&num<=99){
"他是两位数"
}
}
}
import java.util.Scanner; public class test { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("请输入:"); int number = input.nextInt(); int count = 0; if(number == 0){ System.out.println("它是个1位的数"); }else{ while(number != 0){ number /= 10; count++; } System.out.println("它是个"+count+"位的数"); } } }
if (num >= 0 && num<=999999999){
while(num != 0){
count++;
num/=10;
}
System.out.println("它是个"+ count+"位的数!");
} else{
System.out.println("输入有误!");
}
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题