while 1:
try:
#這一段在做的是把所有的0123456789 要出現-或|的把他標記起來
a = [1,0,1,1,0,1,1,1,1,1] #1就是有- 0就是空白
b = [2,3,3,3,2,1,1,3,2,2] #1是| 2是| | 3是 |
c = [0,0,1,1,1,1,1,0,1,1]
d = [2,3,1,3,3,3,2,3,2,3]
e = [1,0,1,1,0,1,1,0,1,1]
num_LC = {0 : " ",
1 : "-"}
space = " "
n = list(input().split(" "))
f = int(n[0])
number = list(map(int,n[1]))
if f == 0 and n[1] =="0":
break
#第一排
for i in number:
print(f" {num_LC[a[i]]*f} ",end = " ") #要印很多個就直接*要的量(f)就好
print()
#第二排
for i in range(0,f):
for i in number:
#判斷是左槓槓 右槓槓 還是兩邊都有槓槓
#中間要放入同f數量的空白
if b[i] == 1:
print("|",space*f,end = " ")
elif b[i] == 2:
print(f"|{space*f}|" ,end = " ")
elif b[i] == 3:
print(space*f,"|" ,end = " ")
else:
print(space*f+2,end = " ")
print()
#第三排
#這裡只要改裡面的abcde就好
for i in number:
print(f" {num_LC[c[i]]*f} ",end = " ")
print()
#第四排
for i in range(0,f):
for i in number:
if d[i] == 1:
print("|",space*f ,end = " ")
elif d[i] == 2:
print(f"|{space*f}|" ,end = " ")
elif d[i] == 3:
print(space*f,"|" ,end = " ")
else:
print(space*f+2,end = " ")
print()
#第五排
for i in number:
print(f" {num_LC[e[i]]*f} ",end = " ")
print()
except:
break
步驟合併起來就如下所示
while 1:
try:
#橫的
def h(number,location):
num_LC = {0 : " ",
1 : "-"}
for i in number:
print(f" {num_LC[location[i]]*f} ",end = " ")
print()
#直的
def v(number,location):
for i in range(0,f):
for i in number:
if location[i] == 1:
print("|",space*f,end = " ")
elif location[i] == 2:
print(f"|{space*f}|" ,end = " ")
elif location[i] == 3:
print(space*f,"|" ,end = " ")
else:
print(space*f+2,end = " ")
print()
a = [1,0,1,1,0,1,1,1,1,1]
b = [2,3,3,3,2,1,1,3,2,2]
c = [0,0,1,1,1,1,1,0,1,1]
d = [2,3,1,3,3,3,2,3,2,3]
e = [1,0,1,1,0,1,1,0,1,1]
space = " "
n = list(input().split(" "))
f = int(n[0])
number = list(map(int,n[1]))
if f == 0 and n[1] =="0":
break
h(number,a)
v(number,b)
h(number,c)
v(number,d)
h(number,e)
except:
break