打印空心字符

 1 #include <stdio.h>
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4  
 5 int main()
 6 {
 7     char start = 'Z';
 8     int high=5,i,j;  //高度可设
 9 
10     //上半部
11     for (i=0; i<high; i++)
12     {
13         //空格
14         for (j=1;j<high-i;j++)
15             printf ("  ");
16         //字符、空格、字符
17         printf ("%c ",start-i);    
18         for (j=0;j<2*i-1;j++)
19             printf ("  ");
20         if (i){    
21             start--;
22             printf ("%c ",start-i);
23         }
24         //换行    
25         printf ("
");
26     }
27 
28     start -= 2*(high-1);
29     //下半部
30     for (i=high-1; i>0 ;i--)
31     {
32         //空格
33         for (j=0;j<high-i;j++)
34             printf ("  ");
35         //字符、空格、字符
36         printf ("%c ",start+i);
37         for (j=0;j<2*i-3;j++)
38             printf ("  ");
39         if (i-1){
40             start--;
41             printf ("%c ",start+i);
42         }    
43         //换行
44         printf ("
");
45     }
46 
47     return 0;
48 }
原文地址:https://www.cnblogs.com/GoldenEllipsis/p/11575688.html