📄 pku1102.txt
字号:
LC-Display
Time Limit:1000MS Memory Limit:10000K
Total Submit:3491 Accepted:1401
Description
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 contains several lines, one for each number to be displayed. Each line contains two integers s, n (1 <= s <= 10, 0 <= n <= 99 999 999), 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
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
Source
Mid-Central European Regional Contest 1999
Source
Problem Id:1102 User Id:Drizzle
Memory:268K Time:0MS
Language:G++ Result:Accepted
Source
/*
农夫三拳@seu
drizzlecrj.gmail.com
2007-03-02
*/
#include <iostream>
#include <cstring>
using namespace std;
char map[300][300];
int s, n;
int digitNum;
int digits[10];
void Fill(int s, int n)
{
int startx, starty;
int i, j;
startx = starty = 0;
for(i = digitNum - 1; i >= 0; i--)
{
if(digits[i] == 1)
{
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
}
else if(digits[i] == 2)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
else if(digits[i] == 3)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
else if(digits[i] == 4)
{
for(j = startx + 1; j <= startx + s; j++)
map[j][starty] = '|';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
}
else if(digits[i] == 5)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
else if(digits[i] == 6)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty] = '|';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
else if(digits[i] == 7)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
}
else if(digits[i] == 8)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty] = '|';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty] = '|';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
else if(digits[i] == 9)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty] = '|';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + 1][j] = '-';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
else if(digits[i] == 0)
{
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx][j] = '-';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty] = '|';
for(j = startx + 1; j <= startx + s; j++)
map[j][starty + s + 1] = '|';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty] = '|';
for(j = startx + s + 2; j <= startx + s + s + 1; j++)
map[j][starty + s + 1] = '|';
for(j = starty + 1; j < starty + 1 + s; j++)
map[startx + s + s + 2][j] = '-';
}
starty += s + 3;
}
}
void Output()
{
for(int i = 0; i < s + s + 3; i++)
{
for(int j = 0; j < (s+3)*digitNum - 1; j++)
cout << map[i][j];
cout << endl;
}
cout << endl;
}
void Init()
{
int count = 0;
digitNum = 0;
if(n == 0)
digits[digitNum++] = 0;
while(n > 0)
{
digits[count++] = n % 10;
n /= 10;
digitNum++;
}
}
int main()
{
while(cin >> s >> n && s)
{
memset(map, ' ', sizeof(map));
Init();
Fill(s, n);
Output();
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -