public class forxunhuan {
public static void main(String[] args) {
int a = 5;
for (int i = 1; i <= a; i++) { //i表示行数
for (int k = 1; k <= (a - i); k++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {//j表示列数
if (j == 1 || j == 2 * i - 1 ) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println("");
}
//正三角加倒三角
for (int i = a - 1; i >=1; i--) {
for (int k = 0; k <= a - 1 - i; k++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
if (j == 1 || j == 2 * i - 1) {
System.out.print("*");
}else{
System.out.print(" ");
}
}
System.out.println(" ");
}
}
}
08-09
3259
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-30
3557
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-16
3804
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-09
1402
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-31
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)