# 【題解】ZeroJudge c135: 00706 – LC-Display

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=c135
【解題想法】用 5×3的矩陣來表示每一個數字，方便放大字型。

```#include <iostream>
using namespace std;

int main() {
int g[10][5][3] = {
{0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0}, //0
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, //1
{0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0}, //2
{0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0}, //3
{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0}, //4
{0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0}, //5
{0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, //6
{0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, //7
{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, //8
{0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0}, //9
};
string n;
int s;
while (cin >> s >> n){
if (s == 0) break;
for (int i = 0; i < 5; i++){
if (i % 2){
for (int l = 0; l < s; l++){
for (int j = 0; j < n.size(); j++){
if (g[n[j] - '0'][i][0]) cout << "|";
else cout << " ";
for (int k = 0; k < s; k++){
cout << " ";
}
if (g[n[j] - '0'][i][2]) cout << "|";
else cout << " ";
cout << " ";//在2個數字中間有一空白行。
}
cout << "\n";
}
} else {
for (int j = 0; j < n.size(); j++){
cout << " ";
for (int k = 0; k < s; k++){
if (g[n[j] - '0'][i][1]) cout << "-";
else cout << " ";
}
cout << " ";
cout << " ";//在2個數字中間有一空白行。
}
cout << "\n";
}
}
}
}
```

Python code (credit: Amy Chou)

```g = [
[[0, 1, 0], [1, 0, 1], [0, 0, 0], [1, 0, 1], [0, 1, 0]], #0
[[0, 0, 0], [0, 0, 1], [0, 0, 0], [0, 0, 1], [0, 0, 0]], #1
[[0, 1, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 0]], #2
[[0, 1, 0], [0, 0, 1], [0, 1, 0], [0, 0, 1], [0, 1, 0]], #3
[[0, 0, 0], [1, 0, 1], [0, 1, 0], [0, 0, 1], [0, 0, 0]], #4
[[0, 1, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 1, 0]], #5
[[0, 1, 0], [1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 0]], #6
[[0, 1, 0], [0, 0, 1], [0, 0, 0], [0, 0, 1], [0, 0, 0]], #7
[[0, 1, 0], [1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]], #8
[[0, 1, 0], [1, 0, 1], [0, 1, 0], [0, 0, 1], [0, 1, 0]], #9
]

while True:
s, n = map(str, input().split())
s = int(s)
if s == 0:
break

for i in range (5):
if i % 2 == 1:
for l in range(s):
for j in range(len(n)):
if g[int(n[j])][i][0]:
print("|", end="")
else:
print(" ", end="")

for k in range(s):
print(" ", end="")

if g[int(n[j])][i][2]:
print("|", end="")
else:
print(" ", end="")
print(" ", end="")
print()
else:
for j in range(len(n)):
print(" ", end="")
for k in range(s):
if g[int(n[j])][i][1]:
print("-", end="")
else:
print(" ", end="")

print(" ", end="")
print(" ", end="")
print()

```