多重循環(huán),搞不明白為什么對不了、
import java.util.Scanner;
public class duochongxunhuan2 {
public static void main(String[] args){
? ? ? ? ? Scanner in = new Scanner(System.in);
? ? ? ? ? System.out.println("請輸入1~999999999之間的數(shù)字 ");
? ? ? ? ? int t = in.nextInt();
? ? ?int a = 0;
? ? ?int b = 0;
if(a>=1&&a<=999999999){
? ? ? ?while(a>=1){
? ? ? ?a=a/10;
? ? ? ?b++;
????}?
????System.out.println("這是個"+(b-1)+"位數(shù)");
?}else{
?System.out.println("輸入有誤");
?}
? ? ? ? ? ? ?
}
}
2016-06-16
import java.util.Scanner;
public class duochongxunhuan2 {
public static void main(String[] args){
?Scanner in=new Scanner (System.in);
? System.out.println("請輸入a的值:");
? int a=in.nextInt();
?int b = 0;
?
?
if(a>=1&&a<=999999999){
while(a>=1){
a=a/10;
b++;
}?
System.out.println("這是個"+b+"位數(shù)");
?}else{
?System.out.println("輸入有誤");
?}
? ? ? ? ? ? ?
}
}
對對對,終于搞好了 ?好難啊 ? 哈哈哈哈
2016-06-16
你的t沒使用?。?/p>