LC-Display
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 377 Accepted Submission(s): 143
Problem 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
Sample Output
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
Source
Mid-Central European Regional Contest 1999 代码:
#include<iostream>
#include<string.h>
using namespace std
;
int bj
;
void K
(int n
)
{
int i
;
for(i
=0;i
<=n
+1;i
++) cout
<<" ";
if(bj
)
{ cout
<<endl
;
}
}
void H
(int n
)
{
int i
; cout
<<" ";
for(i
=0;i
<n
;i
++) cout
<<"-"; cout
<<" ";
if(bj
) cout
<<endl
;
}
void LL
(int n
)
{
int i
; cout
<<"|";
for(i
=0;i
<n
;i
++) cout
<<" "; cout
<<"|";
if(bj
)cout
<<endl
;
}
void Lq
(int n
)
{
int i
; cout
<<"|";
for(i
=0;i
<=n
;i
++) cout
<<" ";
if(bj
) cout
<<endl
;
}
void Lh
(int n
)
{
int i
;
for(i
=0;i
<=n
;i
++) cout
<<" "; cout
<<"|";
if(bj
)cout
<<endl
;
}
void f
(int n
,int k
,int t
)
{
if(t
%2)
{
if(n
==1||n
==0&&t
==3||n
==4&&t
!=3||n
==7&&t
!=1) K
(k
);
else H
(k
);
}
else if(t
==2)
{
if(n
&&n
<4||n
==7) Lh
(k
);
else if(n
==5||n
==6) Lq
(k
);
else LL
(k
);
}
else
{
if(n
%2||n
==4) Lh
(k
);
else if(n
==2) Lq
(k
);
else LL
(k
);
}
}
int main()
{
char ch
[20];
int a
[20],i
,j
=0,k
,n
,m
,l
;
while(cin
>>n
>>ch
)
{ l
=strlen
(ch
);
for(i
=0;i
<l
;i
++) a
[i
]=ch
[i
]-'0';
if(n
==0&&l
==1&&a
[0]==0)break;
if(l
==1)bj
=1;
else bj
=0; f
(a
[0],n
,1);
for(i
=1;i
<l
;i
++)
{ bj
=0;
if(i
==l
-1) bj
=1; cout
<<" "; f
(a
[i
],n
,1);
}
for(k
=0;k
<n
;k
++)
{ bj
=0;
if(l
==1)bj
=1; f
(a
[0],n
,2);
for(i
=1;i
<l
;i
++)
{ bj
=0;
if(i
==l
-1) bj
=1; cout
<<" "; f
(a
[i
],n
,2);
}
} bj
=0;
if(l
==1)bj
=1; f
(a
[0],n
,3);
for(i
=1;i
<l
;i
++)
{ bj
=0;
if(i
==l
-1) bj
=1; cout
<<" "; f
(a
[i
],n
,3);
}
for(k
=0;k
<n
;k
++)
{ bj
=0;
if(l
==1)bj
=1; f
(a
[0],n
,4);
for(i
=1;i
<l
;i
++)
{ bj
=0;
if(i
==l
-1) bj
=1; cout
<<" "; f
(a
[i
],n
,4);
}
} bj
=0;
if(l
==1)bj
=1; f
(a
[0],n
,5);
for(i
=1;i
<l
;i
++)
{ bj
=0;
if(i
==l
-1) bj
=1; cout
<<" "; f
(a
[i
],n
,5);
} cout
<<endl
;
}
return 0;
}