- 输出1-50中能被2整除的数,每行3个
- 思想:每行3个,第一行判断到6时,换行,第二行判断到12时换行,即每行判断到6的倍数时换行
public class Application {
public static void main(String[] args) {
for (int i = 0; i < 50; i++) {
if (i % 2 == 0) {
System.out.print(i+" ");
}
if (i%(2*3)==0){ //每3个换行,2*3刚好是6的倍数
System.out.println();
}
}
}
}