public static void main(String[] args) {
for (int j = 0;j < 17;j++) {//打印9行
for (int i = 0;i < Math.abs(9 - 1 - j);i++) {
System.out.print(" ");
}
for (int i = 0;i < j * 2 + 1;i++) {
if(j < 9) {
if (i == 0 || i == j * 2 + 1 - 1) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
else {
if(i == 0 || i == 31 - (j * 2 + 1 - 1)){
System.out.print("*");
}
System.out.print(" ");
}
}
System.out.println(" ");
}
原文:https://www.cnblogs.com/shaonianteng/p/10391896.html