用while或for循环输出1-1000之间能被5整除的数,并且每行输出4个

public class ForDemo1 {
    public static void main(String[] args) {
        //用while或for循环输出1-1000之间能被5整除的数,并且每行输出4个
        for (int i = 0; i <= 1000; i++) {
            if (i%5==0){
                System.out.print(i+"\t");
            }
            if (i%(5*4)==0){
                System.out.println();
            }
        }
        //print:输出完会换行
        //println:输出完不会换行
    }
}
posted @ 2021-05-24 21:19  Henry`  阅读(431)  评论(0)    收藏  举报