輸出100以內所有6的倍數,每5個一行。


 1 /*
 2           輸出100以內所有6的倍數,每5個一行
 3  */
 4 public class Demo {
 5     public static void main(String[] args){
 6         System.out.println("100以內所有6的倍數:");
 7         int num = 0;
 8         for (int i = 1; i < 100 ; i++) {
 9             if (i%6 == 0){
10                 System.out.print(i + ",");
11                 num++;
12             }
13             if (num == 5){
14                 System.out.println();
15                 num = 0;
16             }
17         }
18     }
19 }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM