public class Test {
public static void main(String[] args) {
StringBuffer str = new StringBuffer("*");
int length = 5;
for (int i = 0; i < length; i++) {
for (int length1 = length-1-i; length1 > 0; length1--) {
System.out.print(" ");
}
System.out.println(str);
str.append("**");
}
str.delete(0,2);
for (int i = length; i > 0; i--) {
for (int i1 = -1; i1 < length-i; i1++) {
System.out.print(" ");
}
System.out.println(str.delete(0,2));
}
}
}
java 打印菱形(for循环打印)
最新推荐文章于 2023-12-18 21:04:15 发布