Auto commit

上级 5b0ce43e
class Main { // 定义一个名为 Main 的类
public class Main {
// main 方法是程序的入口
public static void main(String[] args) { public static void main(String[] args) {
// 输出 "Hello world!" 字符串到控制台
System.out.println("Hello world!"); System.out.println("Hello world!");
// 调用嵌套五层循环的函数
nestedLoop();
} }
}
\ No newline at end of file // 定义嵌套五层循环的函数,使用 for 循环输出所有的数字组合
public static void nestedLoop() {
// 嵌套五层循环
for (int a = 0; a < 10; a++) { // 第一层循环,变量 a 从 0 到 9 迭代
for (int b = 0; b < 10; b++) { // 第二层循环,变量 b 从 0 到 9 迭代
for (int c = 0; c < 10; c++) { // 第三层循环,变量 c 从 0 到 9 迭代
for (int d = 0; d < 10; d++) { // 第四层循环,变量 d 从 0 到 9 迭代
for (int e = 0; e < 10; e++) { // 第五层循环,变量 e 从 0 到 9 迭代
System.out.println(a + " " + b + " " + c + " " + d + " " + e); // 在控制台中输出所有的数字组合
}
}
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册