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 }