根据输入的奇数数字打印出菱形图案,如下图分别为输入5、7、9的对应图案
去这看看
https://blog.csdn.net/qq_37644380/article/details/72822202
class ForForTest {
public static void main(String[] args) {
/*
输出如下图形: 行数i: 空格数j: “*”数目z:
* 1 3 1
*** 2 2 3
***** 3 1 5
******* 4 0 7
***** 1 1 5 6
*** 2 2 3 5
* 3 3 1 4
*/
for (int i = 1;i <= 4;i++){
for (int j = 1;j <= 4 - i;j++) {
System.out.print(" ");
}
for (int z = 1;z <= i*2-1;z++){
System.out.print("*");
}
System.out.println();
}
for (int i = 1;i <= 3;i++){
for (int j = 1;j <= i;j++){
System.out.print(" ");
}
int y = 3;
for (int z = 5;z >= 2*i-1;z--){
System.out.print("*");
}
System.out.println();
}
}
}