Problem H: 液晶显示

Time Limit: 1 Sec  Memory Limit: 32 MB
Submit: 3246  Solved: 1594
[Submit][Status][Web Board]

Description

你的朋友刚买了一台新电脑,他以前用过的最强大的计算工具是一台袖珍计算器。现在,看着自己的新电脑,他有点失望,因为他更喜欢计算器上的LC显示器。所以,你决定写一个LC显示风格的程序帮他在电脑上显示数字。

Input

输入包括若干行,每一行有两个整数。输入为两个0表示结束,并且此行不被处理。

每行输入的两个整数s和n,满足1<=s<=10且0<=n<=99 999 999,其中n是要被现实的数字,s是n应该显示的大小(放大的倍数)。

Output

输出的数字是LC显示风格的:使用s个“-”表示水平线和s个“|”竖直线,每个数字刚好占据s+2列和2s+3行,所有没有“-”和“|”的空白处请用空格填满。并且每两个数字之间要有一列空格。

每一行输入数字对应上述一组LC显示风格输出。任意两组数字的输出之间用一个空行分割。

Sample Input

2 123453 678900 0

Sample Output

-- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | || | | | | | | || | | | | | | | --- --- --- | | | | | | | || | | | | | | || | | | | | | | --- --- --- ---

HINT

Append Code

这个题目挺简单的,枚举每个数字,按字符串接收第二个数字,直接输出就可以了,枚举每个数字时由于打印方式是有规律的,所以可以先写几个函数,方便下面使用。感觉自己这样分十个数字代码太长了,有好方法请多多指教啦。
下面是我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h> int qipan[40][150]; void shu(int i, int k, int num)
{
int n = i + num;
for(; i < n; i++)
qipan[i][k] = -1;
} void heng(int i, int k, int num)
{
intj;
for(j = k + 1; j < k + num + 1; j++)
qipan[i][j] = 1;
} void deal(int n, int num, int k)
{
switch(n)
{
case0:
shu(1, k, num);
shu(num + 2, k, num);
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
heng(0, k, num);
heng(2 * num + 2, k, num);
break;
case1:
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
break;
case2:
heng(0, k, num);
heng(num + 1, k, num);
heng(2 * num + 2, k, num);
shu(1, k + num + 1, num);
shu(num + 2, k, num);
break;
case3:
heng(0, k, num);
heng(num + 1, k, num);
heng(2 * num + 2, k, num);
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
break;
case4:
shu(1, k, num);
heng(num + 1, k, num);
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
break;
case5:
heng(0, k, num);
heng(num + 1, k, num);
heng(2 * num + 2, k, num);
shu(1, k, num);
shu(num + 2, k + num + 1, num);
break;
case6:
shu(1, k, num);
shu(num + 2, k, num);
heng(0, k, num);
heng(num + 1, k, num);
heng(2 * num + 2, k, num);
shu(num + 2, k + num + 1, num);
break;
case7:
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
heng(0, k, num);
break;
case8:
shu(1, k, num);
shu(num + 2, k, num);
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
heng(0, k, num);
heng(num + 1, k, num);
heng(2 * num + 2, k, num);
break;
case9:
shu(1, k, num);
shu(1, k + num + 1, num);
shu(num + 2, k + num + 1, num);
heng(0, k, num);
heng(num + 1, k, num);
heng(2 * num + 2, k, num);
break;
}
} int main()
{
int num, temp = 0;
char s[10];
while(scanf("%d %s", &num, s) && num)
{
if(temp++)
printf("\n");
memset(qipan, 0, sizeof(qipan));
int i,j,k,n = strlen(s);
for(i = 0, k = 0; i < n; i++, k += num + 2)
{
if(k != 0)
k++;
deal(s[i] - '0', num, k);
}
for(i = 0; i < 2 * num + 3; i++)
{
for(j = 0; j < (num + 3) * n - 1; j++)
{
if(qipan[i][j] == 0)
printf(" ");
elseif(qipan[i][j] == 1)
printf("-");
else
printf("|");
}
printf("\n");
}
}
return0;
}


最新文章

  1. SQL Server恢复软件 Stellar Phoenix sql recovery
  2. NOIP2008双栈排序[二分图染色|栈|DP]
  3. 2016 CCPC 合肥赛区 平行四边形//打铁记录..... 背锅还是我在行 此处@ctr 233
  4. Shell脚本_判断根分区使用率
  5. js第一天
  6. ASP.NET MVC如何实现自定义验证(服务端验证+客户端验证)
  7. UVA - 11637 Garbage Remembering Exam (组合+可能性)
  8. kworker
  9. python webdriver 环境搭建详解
  10. 使用MagickNet编辑图片
  11. ViewPager+Fragment切换卡顿解决办法
  12. discuz优化10个小技巧
  13. show processlist结果筛选(转)
  14. IDEA有用插件总结
  15. Oracle 导入导出 dmp 文件
  16. Java游戏服务器成长之路——你好,Mongo
  17. del
  18. ansible 提示安装sshpass
  19. JQuery制作网页——第九章 表单验证
  20. Solr第二讲——SolrJ客户端的使用与案例

热门文章

  1. scp 可以在 2个 linux 主机间复制文件
  2. left join \ right join \ inner join 详解
  3. 【Unity3D】实现太阳系
  4. ajax在购物车中的应用
  5. Android 调节图片工具类
  6. 判断JS数据类型的几种方法
  7. CRC检错技术原理
  8. Jenkins上svn更新策略说明
  9. 重写strcat函数,以实现strcat的功能
  10. json格式引起的 parse 报错