為什么不適用于100.10.220.。等等 的整十的數
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(count=0;count<10;count++){
???
num=num/10;
??? if(num<=1){
????? count++;
????? break;
??? }
}
??????? System.out.println("它是個"+count+"位的數!");
}
}
2015-06-04
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(count=0;count<10;count++){
???
num=num/10;
??? if(num<=0){
????? count++;
????? break;
??? }
}
??????? System.out.println("它是個"+count+"位的數!");
}
}
2015-05-21
public class HelloWorld{
public static void main(String[] args){
int num = 2364724;
?? ??? ?int count =0;
?? ??? ?? for(;num>=1;){
?? ??? ??? ?? count++;
?? ??? ??? ?? num = num / 10;
?? ??? ?? }
??????? System.out.println("它是個"+count+"位的數!");
}
}
你的邏輯有點問題 ,仔細想想就可以了!