1 #include<stdio.h>
2
3 int main(void)
4 {
5 int n;
6
7 scanf_s("%d", &n);
8
9 for (int i = 1; i <= n / 2; i++)
10 {
11 for (int j = i; j <= n / 2; j++)
12 {
13 printf(" ");
14 }
15 for (int j = 1; j <= i * 2 - 1; j++)
16 {
17 printf("* ");
18 }
19 printf("\n");
20 }
21
22 for (int i = 1; i <= n; i++)
23 {
24 printf("* ");
25 }
26 printf("\n");
27
28 for (int i = 1; i <= n/2; i++)
29 {
30 for (int j = i; j <= i * 2 - 1; j++)
31 {
32 printf(" ");
33 }
34 for (int j = 1; j <= n - i * 2; j++)
35 {
36 printf("* ");
37 }
38 printf("\n");
39 }
40
41 return 0;
42 }
![](https://img2018.cnblogs.com/common/1315374/201911/1315374-20191118084342498-156307495.jpg)