import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入菱形的层高(层高为奇数):");
int num = sc.nextInt();
// 控制输入层高为奇数
while (num % 2 == 0) {
System.out.println("输入错误,请重新输入:");
num = sc.nextInt();
}
for (int i = 0; i < num; i++) {
for (int j = 0; j < num; j++) {
// 打印实心菱形,==则是打印空心菱形
if (Math.abs(i - (num - 1) / 2) + Math.abs(j - (num - 1) / 2) <= (num - 1) / 2) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.print("
");
}
}
}