package com.a.b;
public class PrintSquare {
public static void main(String[] args) {
int sideLength = 5; // 设置正方形的边长
printSquare(sideLength);
}
public static void printSquare(int sideLength) {
for (int i = 0; i < sideLength; i++) {
for (int j = 0; j < sideLength; j++) {
System.out.print("* "); // 打印星号,并在每个星号后添加空格
}
System.out.println(); // 换行
}
}
}
12-26
1222
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-13
989
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-11
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交