這樣寫一個循環(huán)體就結束了,想不到要用二重循環(huán)
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+"位的數(shù)");
? ? }
}
2023-07-16
我覺得這樣也行吧,到底有啥區(qū)別呢
2022-05-03
沒有問題要創(chuàng)造問題,加個給出x位數(shù)最大值的功能???
2021-08-19
你這樣寫只適用于這一個例子,嵌套循環(huán)是解決大多數(shù)類似問題,適用性更廣