java流程控制之 while循环 1到1000中能被5整除的数 按3个数据一行输出

package struct;

public class Demo07 {
    public static void main(String[] args) {
        int a = 1;
        int count=0;
        while (a <= 1000) {
            if (a % 5 == 0) {
                System.out.print(a+"\t");
                count++;
            }
//            if (a % (5 * 3) == 0) {
            a++;
            if (count%3 == 0) {
                System.out.println();
            }
        }
    }
}

posted @ 2021-07-29 09:48  阿向向  阅读(335)  评论(0编辑  收藏  举报