The description is omitted and the code is displayed directly.
Code:
1 # include "stdio. H "2 3/* output solid diamond */4 int output_1 (int A) 5 {6 int I, j, n, m; 7 printf ("The following are solid images \ n"); 8 m = A/2 + 1; 9 for (j = 1; j <= A; j ++) 10 {11 N = (m-j); 12 if (n <0) 13 N =-N; 14 for (I = 1; I <= A; I ++) 15 {16 if (I <= n | I> = 1 + a-n) 17 putchar (''); 18 else19 putchar ('*'); 20} 21 putchar ('\ n'); 22} 23 return 1; 24} 25 26/* output hollow diamond */27 int output_2 (int) 28 {29 int I, j, m, n; 30 m = A/2 + 1; 31 printf ("The following are hollow figures \ n "); 32 For (j = 1; j <= A; j ++) 33 {34 N = (m-j); 35 if (n <0) 36 n =-N; 37 For (I = 1; I <= A; I ++) 38 {39 if (I = n + 1 | I = A-N) 40 putchar ('*'); 41 else42 putchar (''); 43} 44 putchar ('\ n'); 45} 46 Return 1; 47} 48 49 int main () 50 {51 int N, choose; 52 while (1) 53 {54 printf ("enter an odd number. N = "); 55 scanf (" % d ", & N); 56 If (N % 2) 57 {58 printf (" select print diamond type: 1. solid; 2. hollow. \ nchoose = "); 59 scanf (" % d ", & choose); 60 if (choose = 1) output_1 (n); 61 else if (choose = 2) output_2 (n); 62 else printf ("error. \ n "); 63} 64} 65 66 return 0; 67}