輸出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 }

原文出處:https://www.cnblogs.com/wangjixue/p/12118929.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章