這樣寫一個循環體就結束了,想不到要用二重循環
public class HelloWorld{
public static void main(String[] args){
? ? int num = 999999999;
? ? int count = 0;
? ? int i;
? ? ? ? for (i=1;i<=num;i=i*10){
? ? ? ? ? ? count++;
? ? ? ? }
? ? ? ? System.out.println("它是個"+count+"位的數");
? ? }
}
2023-07-16
我覺得這樣也行吧,到底有啥區別呢
2022-05-03
沒有問題要創造問題,加個給出x位數最大值的功能???
2021-08-19
你這樣寫只適用于這一個例子,嵌套循環是解決大多數類似問題,適用性更廣