判斷一個數(小于10位)的位數。 輸入999,則輸出 “它是個3位的數!
public class HelloWorld{ public static void main(String[] args){ int num = 999; int count = 0; if(count<10){ for (;num!=0;count++){ ? ?num/=10; }System.out.print("它是個"+count+"位的數!"); }else{ ? ?System.out.print("數據不正確!"); } } } 輸出沒錯,但是為什么提交顯示失敗?
2017-04-08
if 和for循環寫錯了 ,把兩者的條件換過來。