《挑战编程》之液晶显示器

 

最近在看老美的一本《挑战编程》,感觉这书挺有意思的,只是没有答案。做了几道,可能是因为开头的几道不算难吧,感觉还算顺利。

 

题目如下,没有翻译,见谅哈

 

1.6.4 LCD Display


PC/UVa IDs: 110104/706, Popularity: A, Success rate: average Level: 1


A friend of yours has just bought a new computer. Before this, the most powerful
machine he ever used was a pocket calculator. He is a little disappointed because he
liked the LCD display of his calculator more than the screen on his new computer! To
make him happy, write a program that prints numbers in LCD display style.


Input
The input file contains several lines, one for each number to be displayed. Each line
contains integers s and n, where n is the number to be displayed (0 ≤ n ≤ 99, 999, 999)
and s is the size in which it shall be displayed (1 ≤ s ≤ 10). The input will be terminated
by a line containing two zeros, which should not be processed.

Output
Print the numbers specified in the input file in an LCD display-style using s “-” signs
for the horizontal segments and s “|” signs for the vertical ones. Each digit occupies
exactly s + 2 columns and 2s + 3 rows. Be sure to fill all the white space occupied by
the digits with blanks, including the last digit. There must be exactly one column of
blanks between two digits.
Output a blank line after each number. You will find an example of each digit in the
sample output below.

 

Sample Input
2 12345
3 67890
0 0

 

Sample Output
……(显示不出来,有点像搜狗的酷字,大家运行一下就知道了)

 

代码如下:

 

 

代码中的头文件<Fatal.h>是我自己编写的一个出错处理,该头文件是用宏定义的,打印用户传递的字符串;

定义VER1和VER2是为了使用两个不同的版本,我觉得VER2更好。

不过我觉得,使用全局数组不算是很好的办法,期待更好的办法。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值