/**
* 测试循环
*/
public class Testwhile {
public static void main(String[] args) {
int a = 1;
while (a <= 3000) {
System.out.println("I love U!" + a + " 遍");
a++;
}
//0-120之间数字,打印出能被5整除的数字
int i = 0;
while (i <= 120) {
if (i % 5 == 0) {
System.out.println("0-120中,能被5整除的数字" + i);
}
i++;
}
//打印0-130,每行显示7个
int j =0;
while (j<=130){
System.out.print(j+"\t");
if((j+1)%7==0){
System.out.println("\n");
}
j++;
}
}
}
测试While循环 | 0-120之间的数字,打印能被5整除的数字| //打印0-130,每行显示7个
于 2022-01-22 20:34:43 首次发布