空心菱形
package com.shsxt.task;
public class KongXinLingXing {
public static void main(String[] args) {
for (int x=1;x<5;x++){
for (int y=1;x<5-y;y++){
System.out.print(" ");
}
for (int y=1;y<=2*x-1;y++){
if (y==1 || y==2*x-1 ){
System.out.print("*");
}else {
System.out.print(" ");
}
}
System.out.println("");
}
for (int x=5;x<8;x++){
for (int y=1;y<x-3;y++){
System.out.print(" ");
}
for (int y=1;y<=(8-x)*2-1;y++){
if (y==1 ||y==(8-x)*2-1 ){
System.out.print("*");
}else {
System.out.print(" ");
}
}
System.out.println("");
}
}
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/img_convert/fff0a1794c2f1519c955de64a4e63650.png#pic_center)
|