LCD Display

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 ( 0n99, 999, 999) and s is the size in which it shall be displayed ( 1s10). 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
0 0
Sample Output
1
2
3
4
5
6
7
      --   --        -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        -- 






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <iostream>

#define FOR(i,n) for (int i=0;i<n;i++)

using namespace std;

struct Number
{
  bool alt;
  bool ust;
  bool sagust;
  bool solust;
  bool orta;
  bool sagalt;
  bool solalt;
};

Number n0,n1,n2,n3,n4,n5,n6,n7,n8,n9;
string str;
int n;

void g(Number &x)
{
  x.alt = true;
  x.ust = true;
  x.orta = true;
  x.sagalt = true;
  x.solalt = true;
  x.sagust = true;
  x.solust = true;
}

void init()
{
  g(n0); g(n1); g(n2); g(n3); g(n4);
  g(n5); g(n6); g(n7); g(n8); g(n9);
  n0.orta = false; n1.ust = false;
  n1.alt = false; n1.orta = false;
  n1.sagust = false; n1.sagalt = false;
  n2.sagust = false; n2.solalt = false;
  n3.sagalt = false; n3.sagust = false;
  n4.ust = false; n4.alt = false; n4.sagalt = false;
  n5.solust = false; n5.sagalt = false;
  n6.solust = false;
  n7.orta = false; n7.sagalt = false; n7.sagust = false; n7.alt = false;
  n9.sagalt = false;
}

void drawhorizontalline(int n,int c)
{
  cout<<" ";
  FOR(i,n) cout<<"-";
  if (c) cout<<"  ";
  else cout<<" ";
}

void drawverticalline(int n,int c)
{
  cout<<"|";
  if (c) FOR(i,n+2) cout<<" ";
  else FOR(i,n+1) cout<<" ";
}

void drawverticalline2(int n,int c)
{
  cout<<"|";
  FOR(j,n) cout<<" ";
  if (c) cout<<"| ";
  else cout<<"|";
}

void drawverticalline3(int n,int c)
{
  FOR(j,n) cout<<" ";
  if (c) cout<<" | ";
  else cout<<" |";
}

void ust_xett(Number num,int n,int c)
{
  if (num.ust) drawhorizontalline(n,c);
  else
   {
    if (c) FOR(i,n+3) cout<<" ";
    else FOR(i,n+2) cout<<" ";
   }
}
void alt_xett(Number num,int n,int c)
{
  if (num.alt) drawhorizontalline(n,c);
  else
   {
    if (c) FOR(i,n+3) cout<<" ";
    else FOR(i,n+2) cout<<" ";
   }
}
void orta_xett(Number num,int n,int c)
{
  if (num.orta) drawhorizontalline(n,c);
  else
   {
    if (c) FOR(i,n+3) cout<<" ";
    else FOR(i,n+2) cout<<" ";
   }
}
void yuxari_xett(Number num,int n,int c)
{
  if (num.sagust && num.solust) drawverticalline2(n,c);
  else if (num.sagust) drawverticalline(n,c);
  else if (num.solust) drawverticalline3(n,c);
}
void asagi_xett(Number num,int n,int c)
{
  if (num.sagalt && num.solalt) drawverticalline2(n,c);
  else if (num.sagalt) drawverticalline(n,c);
  else if (num.solalt) drawverticalline3(n,c);

}

Number ret(char s)
{
  if (s == '0') return n0;
  if (s == '1') return n1;
  if (s == '2') return n2;
  if (s == '3') return n3;
  if (s == '4') return n4;
  if (s == '5') return n5;
  if (s == '6') return n6;
  if (s == '7') return n7;
  if (s == '8') return n8;
  if (s == '9') return n9;
}

int main()
{
  init();
  while (cin>>n>>str && n != 0)
  {
  for (int i=0;i<str.length();i++)
   {
    if (i < str.length()-1) ust_xett(ret(str[i]) , n , 1);
    else ust_xett(ret(str[i]) , n , 0);
   }
  cout<<endl;
  FOR(i,n)
   {
    for (int i=0;i<str.length();i++)
     {
      if (i < str.length()-1) yuxari_xett(ret(str[i]) , n ,1);
      else yuxari_xett(ret(str[i]) , n , 0);
     }
    cout<<endl;
   }
  for (int i=0;i<str.length();i++)
   {
    if (i < str.length()-1) orta_xett(ret(str[i]) , n , 1);
    else orta_xett(ret(str[i]) , n , 0);
   }
  cout<<endl;
  FOR(i,n)
   {
    for (int i=0;i<str.length();i++)
     {
      if (i < str.length()-1) asagi_xett(ret(str[i]) , n ,1);
      else asagi_xett(ret(str[i]) , n , 0);
     }
    cout<<endl;
   }
  for (int i=0;i<str.length();i++)
   {
    if (i < str.length()-1) alt_xett(ret(str[i]) , n , 1);
    else alt_xett(ret(str[i]) , n , 0);
   }
    cout<<endl;
  }
  return 0;
}
Seems like a lot of work. I would just tell my friend he's being an idiot. Problem solved.
Topic archived. No new replies allowed.