空心菱形
public class Triangle{
public static void main(String[] args){
printHollowRhombus(20);//size是最大间隔距离
}
public static void printHollowRhombus(int size){
for(int i=0;i<size/2+1;i++) {
for (int a = 0; a < size / 2-i; a++) {
System.out.print(" ");
}
for(int b=0;b<2*i+1;b++){
if(b==0||b==2*i)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for(int i=0;i<size/2;i++){
for(int a=0;a<i+1;a++){
System.out.print(" ");
}
for(int b=0;b<size-1-2*i;b++){
if(b==0||b==size-2-2*i)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}