如何使用"while (true) {.}“将这两个While循环转换为其他两个while循环(输出应该是相同的),并在循环中使用"if”和“断开”来终止循环?
输出量
0 1 2 3 4 5 6 7
42 36 30 24 18 12 6 int m = 0;
while (m <= 7) {
System.out.print(m + " ");
m++;
}
System.out.println();
int MM = 42;
while (MM >= 6) {
System.out.print(MM + " ");
MM -= 6;
}
System.out.println();发布于 2022-11-10 14:55:55
int m = 0;
while (true){
System.out.print(m + " ");
m++;
if(m > 7){
break;
}
}
System.out.println();
int MM = 42;
while (true) {
System.out.print(MM + " ");
MM -= 6;
if(MM < 6){
break;
}
}
System.out.println();https://stackoverflow.com/questions/74390912
复制相似问题