空心菱形
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("");
}
}
}

|