#include <iostream>
#define MAX_R 30
#define MAX_C 120
using namespace std;
char res[MAX_R][MAX_C];
int dNum, num;
int digit[10];
int r, c, wide;
void init()
{
//dNum = 0;
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)
res[i][j] = ' ';
}
void getDigit(int temp)
{
if(temp <= 10)
digit[++dNum] = temp;
else
{
getDigit(temp / 10);
digit[++dNum] = temp % 10;
}
}
void fill()
{
int seq, curDigit, startC, endC, midR, tr, tc;
for(seq = 1; seq <= dNum; seq++)
{
curDigit = digit[seq];
startC = (seq - 1) * (wide + 3) + 1;
endC = seq * (wide + 3) - 1;
midR = 2 + wide;
for(tr = 1; tr <= r; tr++)
{
for(tc = startC; tc <= endC; tc++)
{
if(tr == 1 && tc > startC && tc < endC)
{
if(curDigit != 1 && curDigit != 4)
res[tr][tc] = '-';
}
else if(tc == startC && tr > 1 && tr < midR)
{
if(curDigit != 1 && curDigit != 2 && curDigit != 3 && curDigit != 7)
res[tr][tc] = '|';
}
else if(tc == endC && tr > 1 && tr < midR)
{
if(curDigit != 5 && curDigit != 6)
res[tr][tc] = '|';
}
else if(tr == midR && tc > startC && tc < endC)
{
if(curDigit != 1 && curDigit != 7 && curDigit != 0)
res[tr][tc] = '-';
}
else if(tc == startC && tr > midR && tr < r)
{
if(curDigit == 2 || curDigit == 6 || curDigit == 8 || curDigit == 0)
res[tr][tc] = '|';
}
else if(tc == endC && tr > midR && tr < r)
{
if(curDigit != 2)
res[tr][tc] = '|';
}
else if(tr == r && tc > startC && tc < endC)
{
if(curDigit != 1 && curDigit != 4 && curDigit != 7)
res[tr][tc] = '-';
}
}
}
}
}
int main()
{
while(cin>>wide>>num && !(wide == 0 && num == 0))
{
dNum = 0;
getDigit(num);
r = 2 * wide + 3;
c = dNum * (wide + 3) - 1;
init();
fill();
for(int tr = 1; tr <= r; tr++)
{
for(int tc = 1; tc <= c; tc++)
cout<<res[tr][tc];
cout<<endl;
}
cout<<endl;
}
return 0;
}
POJ 1102 LC DISPLAY
最新推荐文章于 2022-02-25 19:38:17 发布