各位大神!求助,任务是判断一个数(小于10位)的位数,输入999,则输出“它是个3位的数”
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){
"他是两位数"
}
}
}
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){
"他是两位数"
}
}
}
2016-02-27
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+"位的数"); } } }
举报