首页 > 其他 > 详细

打印空心字符

时间:2019-09-24 00:18:41      阅读:89      评论:0      收藏:0      [点我收藏+]

技术分享图片

 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 ("\n");
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 ("\n");
45     }
46 
47     return 0;
48 }

 

打印空心字符

原文:https://www.cnblogs.com/GoldenEllipsis/p/11575688.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!