int hangshu = 11;
int yiban = hangshu / 2 + 1;
int yibanduo = hangshu / 2;
System.out.println("空心菱形:");
for(int k = 1;k <= yiban;k++){
for(int i = 1;i <= (yiban - k);i++){
System.out.print(" ");
}
System.out.print("*");
for(int i = 1;i <= ( (k - 2) * 2 + 1);i++){
System.out.print(" ");
}
if(k != 1){
System.out.print("*");
}
System.out.println();
}
for(int k = yibanduo;k >=1;k--){
for(int i = 1;i <= (yiban - k);i++){
System.out.print(" ");
}
System.out.print("*");
for(int i = 1;i <= ( (k - 2) * 2 + 1);i++){
System.out.print(" ");
}
if(k != 1){
System.out.print("*");
}
System.out.println();
} |