[UVA] 706 - LC Display
LC-Display
| LC-Display |
A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed, because he liked the LC-display of his calculator so much. So you decide to write a program that displays numbers in an LC-display-like style on his computer.
Input
The input file contains several lines, one for each number to be
displayed. Each line contains two integers s, n (
), where n is the number to be displayed and s
is the size in which it shall be displayed.
The input file will be terminated by a line containing two zeros. This line should not be processed.
Output
Output the numbers given in the input file in an LC-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, also for the last digit.) There has to be exactly one column of blanks between two digits.
Output a blank line after each number. (You will find a sample of each digit in the sample output.)
Sample Input
2 12345 3 67890 0 0
Sample Output
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
總覺得 UVa 好像打成 LCD - Display
#include<stdio.h>
char type[5][6] = {
{" "},{" |"},{"| "},{"| |"},{" -- "},
};
char Num[10][5] = {
{4,3,0,3,4},/*0*/
{0,1,0,1,0},/*1*/
{4,1,4,2,4},/*2*/
{4,1,4,1,4},/*3*/
{0,3,4,1,0},/*4*/
{4,2,4,1,4},/*5*/
{4,2,4,3,4},/*6*/
{4,1,0,1,0},/*7*/
{4,3,4,3,4},/*8*/
{4,3,4,1,4}/*9*/
};
void PrintNum(char s[], int n) {
int a, b, c, tn;
for(a = 0; a < 5; a++) {
if(a == 0 || a == 2 || a == 4) tn = 1;
else tn = n;
while(tn--) {
for(b = 0; s[b]; b++) {
if(s[b] == ' ') {putchar(' ');continue;}
putchar(type[Num[s[b] - '0'][a]][0]);
for(c = 0; c < n; c++)
putchar(type[Num[s[b] - '0'][a]][1]);
putchar(type[Num[s[b] - '0'][a]][3]);
if(s[b+1] != '\0') putchar(' ');
}
puts("");
}
}
}
main() {
int n;
char s[20];
while(scanf("%d %s", &n, s) == 2) {
if(n == 0)
break;
PrintNum(s, n);
puts("");
}
return 0;
}
这个话题真是令人着迷。数字不仅存在于计算和逻辑中,它们在不同文化中也承载着深层含义。如果你对数字背后的命运、能量和人生意义感兴趣,推荐你看看这个网站:
<a href="https://matrixdestiny.net/" target="_blank">https://matrixdestiny.net/</a>
它结合了数字命理、能量中心(脉轮)等内容,从另一个角度带你认识“数字”的神秘力量。了解自己的人生路径和内在潜能,也许就从认识你的“命运矩阵”开始。
对数字的探索,远比我们想象的更广更深。希望对你有所启发!
https://matrixdestiny.net/