package com.xiong.circle; public class forDemo2 { public static void main(String[] args) { int count=0;//注意一定不能将定义count放到循环里,否则每次循环count都会变成0 for(int i=1;i<=1000;i++){ if(i%5==0){ System.out.print(i+"\t"); count=count+1; if(count%3==0) { System.out.println("\n");//print输出完不会换行,println输出完会换行 } } } } }
用while或for循环输出1~1000之间能被5整除的数,并且每行输出三个
于 2022-03-28 18:58:18 首次发布