한 친구가 방금 새 컴퓨터를 샀다. 그 친구가 지금까지 샀던 가장 강력한 컴퓨터는 공학용 전자 계산기였다. 그런데 그 친구는 새 컴퓨터의 모니터보다 공학용 계산기에 있는 LCD 디스플레이가 더 좋다며 크게 실망하고 말았다. 그 친구를 만족시킬 수 있도록 숫자를 LCD 디스플레이 방식으로 출력하는 프로그램을 만들어보자.
입력 파일은 여러 줄로 구성되며 표시될 각각의 숫자마다 한 줄씩 입력된다. 각 줄에는 s와 n이라는 두개의 정수가 들어있으며 n은 출력될 숫자( 0<= n <= 99,999,999 ), s는 숫자를 표시하는 크기( 1<= s < 10 )를 의미한다. 0 이 두 개 입력된 줄이 있으면 입력이 종료되며 그 줄은 처리되지 않는다.
입력 파일에서 지정한 숫자를 수평 방향은 '-' 기호를, 수직 방향은 '|'를 이용해서 LCD 디스플레이 형태로 출력한다. 각 숫자는 정확하게 s+2개의 열, 2s+3개의 행으로 구성된다. 마지막 숫자를 포함한 모든 숫자를 이루는 공백을 스페이스로 채워야 한다. 두 개의 숫자 사이에는 정확하게 한 열의 공백이 있어야 한다.
각 숫자 다음에는 빈 줄을 한 줄 출력한다. 밑에 있는 출력 예에 각 숫자를 출력하는 방식이 나와있다.
입력 예
2 12345
3 67890
0 0
출력 예
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
167개의 풀이가 있습니다.
쉬운 길은 다른 많은 분들이 모두 하셨으니까 저는 어려운 방향으로 해 보겠습니다. 파이썬입니다.
p=1
while p:
p,q=raw_input().split();p=int(p)
if p:
for x in[28728]+[609961108]*p+[14680127]+[340862356]*p+[14708792,-1]:
print' '.join(d[0]+d[1]*p+d[2]for d in[' - | | '[x>>int(j)*3&7:]for j in q])
공백을 모두 제거하면 203바이트까지 줄어듭니다.
table = [
['23567890'],
['456890', '12347890'],
['2345689'],
['2680', '134567890'],
['2356890']
]
e, d, p = ' ', '-', '|'
while True:
s, n = raw_input().split(' ')
if s == '0' and n == '0':
break
s = int(s)
for row in range(0, 5):
t = table[row]
if len(t) == 1:
for digit in n:
c = d if digit in t[0] else e
print (' %s '%(c*s)),
print
else:
for r in range(0, s):
for digit in n:
c = [p if digit in x else e for x in t]
print('%s%s%s '%(c[0], e*s, c[1])),
print
print
테이블을 참고하며 출력합니다.
가로줄(-)을 출력할 때는 if len(t) == 1: 분기를 타고,
세로줄(|)을 출력할 때는 else: 분기를 타는 간단한 구조입니다.
Ruby (버전 1.8.7) 로 해봤습니다. 짧게 줄이다보니 아라크넹님과 알고리즘이 비슷해졌네요. (..하지만 약간 다름)
공백 포함 141바이트입니다.
$_=[28728,609961108,14680127,340862356,14708792].map{|x|~/ /
$'.gsub(/./){k=' - | | '[7&x>>$&.hex*3,4]
k[1,1]*=S=$_.hex
k}.*x%7<1?1:S},$/
압축하면 131바이트가 됩니다.
$_="8p\000\000\224D[$?\000\340\000\224%Q\0248p\340\000".unpack('L*').map{|x|~/ /
$'.gsub(/./){k=' - | | '[7&x>>$&.hex*3,4]
k[1,1]*=S=$_.hex
k}.*x%7<1?1:S},$/
사용법

Sub Main()
Do
'// 입력
Dim input() As String = Console.ReadLine.Split(" ")
Dim size As Integer = Val(input(0)), num As Integer = Val(input(1))
Dim numData()()() As Byte =
New Byte()()() {
New Byte()() {New Byte() {0, 1, 0}, New Byte() {1, 0, 1}, New Byte() {0, 0, 0}, New Byte() {1, 0, 1}, New Byte() {0, 1, 0}},
New Byte()() {New Byte() {0, 0, 0}, New Byte() {0, 0, 1}, New Byte() {0, 0, 0}, New Byte() {0, 0, 1}, New Byte() {0, 0, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 1, 0}, New Byte() {1, 0, 0}, New Byte() {0, 1, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 1, 0}},
New Byte()() {New Byte() {0, 0, 0}, New Byte() {1, 0, 1}, New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 0, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {1, 0, 0}, New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 1, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {1, 0, 0}, New Byte() {0, 1, 0}, New Byte() {1, 0, 1}, New Byte() {0, 1, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 0, 0}, New Byte() {0, 0, 1}, New Byte() {0, 0, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {1, 0, 1}, New Byte() {0, 1, 0}, New Byte() {1, 0, 1}, New Byte() {0, 1, 0}},
New Byte()() {New Byte() {0, 1, 0}, New Byte() {1, 0, 1}, New Byte() {0, 1, 0}, New Byte() {0, 0, 1}, New Byte() {0, 1, 0}}
}
Dim digitChar() As String = {"|", "-"}
For y As Integer = 0 To numData(0).Length - 1
For j As Integer = 1 To size
Dim tmp As String = ""
For Each c As Char In num.ToString.ToArray
Dim n As Integer = CInt(c.ToString)
For x As Integer = 0 To numData(n)(y).Length - 1
For i As Integer = 1 To size
If numData(n)(y)(x) = 0 Then
If i = 1 Or x = 1 Then tmp &= Space(1)
Else
If (x = 1 Or i = 1) And Not (j > 1 And x = 1) Then tmp &= digitChar(x Mod 2)
End If
Next
Next
tmp &= Space(1)
Next
If Trim(tmp).Length > 0 Then Console.WriteLine(tmp)
Next
Next
Loop
Console.ReadLine()
End Sub
def lcd_disp(size, num_str):
# - 0
# | | 1 2
# _ 3
# | | 4 5
# _ 6
_map = [
'1011010111',
'1000111111',
'1111100111',
'0011111011',
'1010001010',
'1101111111',
'1011011010'
]
def _horizon(key):
prt = [' ', '-']
for x in num_str:
print (' {} '.format(prt[int(_map[key][int(x)])] * size), end=' ')
print('')
def _vertical(key1, key2):
prt = [' ', '|']
for i in range(size):
for x in num_str:
print ('{}{}{}'.format(prt[int(_map[key1][int(x)])]
,' ' * size
,prt[int(_map[key2][int(x)])]),
end=' ')
print('')
_horizon(0)
_vertical(1, 2)
_horizon(3)
_vertical(4, 5)
_horizon(6)
lcd_disp(2, '12345')
lcd_disp(3, '67890')
Python 3.5.2에서 작성하였습니다.
안드로이드 펍에서 자바 누가좀 올려줬으면 좋겠다는 분이 계셔서 한번 만들어 봤습니다.
class 는 두개로 나뉘어 졌고, main method 에서 실행하는 코드가 몇줄 있습니다. 생각보다 길어졌네요.
1) 숫자를 뿌려주는 클래스 입니다.
public class Displayer
{
private static Displayer instance;
private static final String horizontal = "-";
private static final String vertical = "|";
private static final String space = " ";
private static final String new_line = "\r\n";
private static final boolean[] NUMBER_FORMAT_TOP = new boolean[] { true, false, true, true, false, true, true, true, true, true };
private static final boolean[] NUMBER_FORMAT_LEFT_TOP = new boolean[] { true, false, false, false, true, true, true, false, true, true };
private static final boolean[] NUMBER_FORMAT_RIGHT_TOP = new boolean[] { true, true, true, true, true, false, false, true, true, true };
private static final boolean[] NUMBER_FORMAT_DIVIDER = new boolean[] { false, false, true, true, true, true, true, false, true, true };
private static final boolean[] NUMBER_FORMAT_LEFT_BOTTOM = new boolean[] { true, false, true, false, false, false, true, false, true, false };
private static final boolean[] NUMBER_FORMAT_RIGHT_BOTTOM = new boolean[] { true, true, false, true, true, true, true, true, true, true };
private static final boolean[] NUMBER_FORMAT_BOTTOM = new boolean[] { true, false, true, true, false, true, true, false, true, true };
private Displayer()
{}
synchronized public static Displayer getInstance()
{
if (instance == null)
instance = new Displayer();
return instance;
}
private int size = 1;
private String number = "0";
public void init(int size, String number)
{
this.size = size;
this.number = number;
width = size + 2;
height = size * 2 + 3;
center = ((height - 1) / 2);
}
private int width, height, center;
public void drawNumbers()
{
if (size == 0 && number.equals("0"))
return;
System.out.print(new_line);
for (int i = 0; i < height; i++)
{
System.out.print(new_line);
for (int n = 0; n < number.length(); n++)
{
System.out.print(space);
int num = Integer.parseInt(number.substring(n, n + 1));
for (int j = 0; j < width; j++)
{
// 첫 줄
if (i == 0)
{
// 첫 칸과 마지막 칸
if (needSpace(j))
System.out.print(space);
else
{
if (NUMBER_FORMAT_TOP[num])
System.out.print(horizontal);
else
System.out.print(space);
}
}
// 마지막 줄
else if (i == (height - 1))
{
// 첫 칸과 마지막 칸
if (needSpace(j))
System.out.print(space);
else
{
if (NUMBER_FORMAT_BOTTOM[num])
System.out.print(horizontal);
else
System.out.print(space);
}
}
// 중간 디바이더
else if (i == center)
{
// 첫 칸과 마지막 칸
if (needSpace(j))
System.out.print(space);
else
{
if (NUMBER_FORMAT_DIVIDER[num])
System.out.print(horizontal);
else
System.out.print(space);
}
}
else
{
// 왼쪽
if (j == 0)
{
// 위
if (i < center)
{
if (NUMBER_FORMAT_LEFT_TOP[num])
System.out.print(vertical);
else
System.out.print(space);
}
// 아래
else
{
if (NUMBER_FORMAT_LEFT_BOTTOM[num])
System.out.print(vertical);
else
System.out.print(space);
}
}
// 오른쪽
else if (j == (width - 1))
{
// 위
if (i < center)
{
if (NUMBER_FORMAT_RIGHT_TOP[num])
System.out.print(vertical);
else
System.out.print(space);
}
// 아래
else
{
if (NUMBER_FORMAT_RIGHT_BOTTOM[num])
System.out.print(vertical);
else
System.out.print(space);
}
}
else
System.out.print(space);
}
}
}
}
}
private boolean needSpace(int j)
{
return (j == 0 || j == (width - 1));
}
}
2) 파일에서 숫자정보를 로드하는 class 입니다.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class FileLoader
{
private static FileLoader instance;
private FileLoader()
{}
synchronized public static FileLoader getInstance()
{
if (instance == null)
instance = new FileLoader();
return instance;
}
File f;
ArrayList<Integer> sizes = new ArrayList<Integer>();
ArrayList<String> numbers = new ArrayList<String>();
public boolean loadFile(String fileName)
{
try
{
if (fileName.contains("\\") || fileName.contains("/"))
f = new File(fileName);
else
f = new File(".\\" + fileName);
FileInputStream fis = new FileInputStream(f);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String s;
while ((s = br.readLine()) != null)
{
String[] line = s.split(",");
if (line != null && s.length() > 1)
{
sizes.add(Integer.parseInt(line[0].trim()));
numbers.add(line[1].trim());
}
}
if (sizes.size() <= 0)
{
System.out.println("sizes format error");
return false;
}
if (numbers.size() <= 0)
{
System.out.println("numbers format error");
return false;
}
if (sizes.get(sizes.size() - 1) != 0)
{
System.out.println("end of list not available");
return false;
}
if (!numbers.get(numbers.size() - 1).equals("0"))
{
System.out.println("end of list not available");
return false;
}
return true;
}
catch (Throwable e)
{
return false;
}
}
public ArrayList<Integer> getSize()
{
return sizes;
}
public ArrayList<String> getNumbers()
{
return numbers;
}
}
3) 두개의 class 를 이용해서 실행하는 코드입니다.
FileLoader loader = FileLoader.getInstance();
Displayer displayer = Displayer.getInstance();
if(loader.loadFile("number.txt"))
{
ArrayList<Integer> sizes = loader.getSize();
ArrayList<String> numbers = loader.getNumbers();
for(int i=0 ; i < sizes.size() ; i++)
{
displayer.init(sizes.get(i), numbers.get(i));
displayer.drawNumbers();
}
}
결과화면은 이렇습니다.
입력
2, 12345
3, 67890
4, 12345
0, 0
출력
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
---- ---- ----
| | | | | |
| | | | | |
| | | | | |
| | | | | |
---- ---- ---- ----
| | | | |
| | | | |
| | | | |
| | | | |
---- ---- ----
감사합니다.
#include "stdafx.h"
#include <string>
char img[] = { 0x77, 0x24, 0x5d, 0x6d, 0x2e, 0x6b, 0x7b, 0x27, 0x7f, 0x6f };
void WriteDot(char* pDispaly,char chStart,char chCenter,char chEnd,int nSize)
{
*pDispaly++ = chStart;
while(nSize--)
*pDispaly++ = chCenter;
*pDispaly = chEnd;
}
void WriteFont(char chDisplay[][32],unsigned char byteData,int nSize,int nIndex)
{
byteData -= '0';
if(byteData <= 9)
{
int nLine = 0;
int nBitIndex = 0;
for(int iter = 0 ; iter < 5 ; iter ++)
{
int nLoop = nSize;
char chStart = ' ',chCenter = ' ',chEnd = ' ';
if( (iter % 2) == 0)
{
if(img[byteData] & 0x01 << nBitIndex++)
chCenter = '-';
nLoop = 1;
}else
{
if(img[byteData] & 0x01 << nBitIndex++)
chStart = '|';
if(img[byteData] & 0x01 << nBitIndex++)
chEnd = '|';
}
while(nLoop--)
WriteDot(&chDisplay[nLine++][nIndex],chStart,chCenter,chEnd,nSize);
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
while(1)
{
char chInput[32];
char chDisplay[32][32];
int nSize = 0;
memset(chInput,0,32);
memset(chDisplay,0,32*32);
printf("?");
scanf("%d %s",&nSize,&chInput);
int iter = 0;
while(chInput[iter] != 0)
{
WriteFont(chDisplay,chInput[iter],nSize,iter*(nSize+2));
iter++;
}
iter = 0;
while(chDisplay[iter][0])
printf("%s\n",chDisplay[iter++]);
}
return 0;
}
오늘 String에 대해서 contains() 메서드를 배워가지고요 ㅋㅋㅋ JAVA로는 가장 짧게 코딩해보려고 노력했습니다. 문자열 String처리를 통해서요 무려 2년전에 올려진 문제네요 ㅋㅋ
package h_LCD_display_num;
import java.util.Scanner;
public class DisplayNum {
public static void main(String[] args) {
int N=20;//Input Limit
String[] hori={"02356789","2345689","2356890"};
String[][] verti={{"045689","01234789"},{"0268","013456789"}};
Scanner in=new Scanner(System.in);
int[] s=new int[N]; String[] n=new String[N];
int L=-1,l,c,i,j,t,v;
do{ s[++L]=in.nextInt(); n[L]=in.next(); }while( s[L]!=0 && n[L]!="0" ); //입력받음
for(l=0;l<L;l++){ //입력한 줄 한줄씩
for(t=0;t<3;t++){
for(c=0;c<n[l].length();c++){ System.out.print(" "); //가로선 ~ c:한 숫자씩
for(i=0;i<s[l];i++) System.out.print((hori[t].contains(n[l].charAt(c)+""))?"-":" ");
System.out.print(" ");
}System.out.println();
if(t<2) for(j=0;j<s[l];j++){ //세로선
for(c=0;c<n[l].length();c++){
for(v=0;v<2;v++){
System.out.print((verti[t][v].contains(n[l].charAt(c)+""))?"|":" ");
if(v==0) for(i=0;i<s[l];i++) System.out.print(" ");
else System.out.print(" ");
}
}System.out.println();
}
}System.out.println();
}
}}
#입출력결과
2 20140316
3 7654
0 0
-- -- -- -- --
| | | | | | | | | | |
| | | | | | | | | | |
-- -- -- --
| | | | | | | | | | |
| | | | | | | | | | |
-- -- -- -- --
--- --- ---
| | | | |
| | | | |
| | | | |
--- --- ---
| | | | |
| | | | |
| | | | |
--- ---
다른언어말고 JAVA로 이보다 더 짧게 줄일 수 있을까요? 시간나면 더 고민해보겠씁니다 ㅋㅋ
r로 풀었습니다
```{r}
f2<-function(...){
f1<-function(s, number){
number<-unlist(strsplit(as.character(number), ""))
a<-length(number)
for(i in 1:a){
cat(" ")
for(j in 1:s){
if(number[i]%in%c("1","4")){
cat(" ")
}else if(number[i]%in%c("2","3","5","6","7","8","9","0")){
cat("-") }}
cat(" ")
cat(" ") }
cat("\n")
for(j in 1:s){
for(i in 1:a){
if(number[i]=="1"){
cat(" ")
for(k in 1:s){
cat(" ") }
cat("|")
}else if(number[i]%in%c("2","3","7")){
cat(" ")
for(k in 1:s){
cat(" ") }
cat("|")
}else if(number[i]%in%c("4","8","9","0")){
cat("|")
for(k in 1:s){
cat(" ") }
cat("|")
}else if(number[i]%in%c("5","6")){
cat("|")
for(k in 1:s){
cat(" ") }
cat(" ") }
cat(" ") }
cat("\n") }
for(i in 1:a){
cat(" ")
for(j in 1:s){
if(number[i]%in%c("1","7","0")){
cat(" ")
}else if(number[i]%in%c("2","3","4","5","6","8","9")){
cat("-") }}
cat(" ")
cat(" ") }
cat("\n")
for(j in 1:s){
for(i in 1:a){
if(number[i]=="1"){
cat(" ")
for(k in 1:s){
cat(" ") }
cat("|")
}else if(number[i]%in%c("3","4","5","7","9")){
cat(" ")
for(k in 1:s){
cat(" ") }
cat("|")
}else if(number[i]%in%c("6","8","0")){
cat("|")
for(k in 1:s){
cat(" ") }
cat("|")
}else if(number[i]%in%c("2")){
cat("|")
for(k in 1:s){
cat(" ") }
cat(" ") }
cat(" ") }
cat("\n") }
for(i in 1:a){
cat(" ")
for(j in 1:s){
if(number[i]%in%c("1","4","7")){
cat(" ")
}else if(number[i]%in%c("2","3","5","6","8","9","0")){
cat("-") }}
cat(" ")
cat(" ") }
cat("\n") }
v<-c(...)
if(v[length(v)]==0&v[length(v)-1]==0){
for(l in 1:((length(v)/2)-1)){
f1(v[2*l-1],v[2*l])
}
}
}
f2(2,12345,3,67890,0,0)
```
#변수 초기화
inputNumber = "123456789012345"
top = 0
bottom = 0
middle = 0
digit = [" # ", " # ","|# "," #|","|#|"]
#문자를 초기화
def initDigit():
digit[0] = " # "
digit[1] = " # "
digit[2] = "|# "
digit[3] = " #|"
digit[4] = "|#|"
#문자를 대입
def makeDigit(x):
linestr = ""
whitestr = ""
for i in range(x):
whitestr += " "
linestr += "-"
for i in range(len(digit)):
if( i == 1):
digit[i] = digit[i].replace('#',linestr)
else :
digit[i] = digit[i].replace('#',whitestr)
#기준 정하기 / 위 / 중간 / 아래
def setCriterion(x):
global top
global middle
global bottom
top = 1
middle = 2+x
bottom = 3+(x*2)
#문자를 LCD 타입으로 표시하기
def textToGraphic(x, line) :
#1
if(x == 1 and ((line == top) or (line == middle) or (line == bottom))) :
return digit[0]
if(x == 1 and ((line != top) or (line != middle) or (line != bottom))) :
return digit[3]
#2
if(x == 2 and ((line == top) or (line == middle) or (line == bottom))) :
return digit[1]
if(x == 2 and (top < line < middle)) :
return digit[3]
if(x == 2 and (middle < line < bottom)) :
return digit[2]
#3
if(x == 3 and ((line == top) or (line == middle) or (line == bottom))) :
return digit[1]
if(x == 3 and ((line != top) or (line != middle) or (line != bottom))) :
return digit[3]
#4
if(x == 4 and (line == top or line == bottom)) :
return digit[0]
if(x == 4 and (top < line < middle)) :
return digit[4]
if(x == 4 and (line == middle)) :
return digit[1]
if(x == 4 and (middle < line < bottom )) :
return digit[3]
#5
if(x == 5 and (line == top or line == middle or line == bottom)) :
return digit[1]
if(x == 5 and (top < line < middle)) :
return digit[2]
if(x == 5 and (middle < line < bottom)) :
return digit[3]
#6
if(x == 6 and (line == top or line == middle or line == bottom)) :
return digit[1]
if(x == 6 and (top < line < middle)) :
return digit[2]
if(x == 6 and (middle < line < bottom)) :
return digit[4]
#7
if(x == 7 and (line == top)) :
return digit[1]
if(x == 7 and (line == middle or line == bottom)) :
return digit[0]
if(x == 7 and (top < line < bottom)) :
return digit[3]
#8
if(x == 8 and (line == top or line == middle or line == bottom)) :
return digit[1]
if(x == 8 and (line != top or line != middle or line != bottom)) :
return digit[4]
#9
if(x == 9 and (line == top or line == middle or line == bottom)) :
return digit[1]
if(x == 9 and (top < line < middle)) :
return digit[4]
if(x == 9 and (middle < line < bottom)) :
return digit[3]
#0
if(x == 0 and (line == top or line == bottom)) :
return digit[1]
if(x == 0 and (line == middle)) :
return digit[0]
if(x == 0 and (line != top or line != middle or line != bottom)) :
return digit[4]
else :
return ""
#LCD display
def lcdDisplay(x):
setCriterion(x) #기준라인 정하기
line=[]
nu = (x * 2)+3
for z in range(nu):
line.append("")
initDigit() # 문자 초기화
makeDigit(x)# 대입 문자 만들기
digitnumber = len(inputNumber) #입력숫자의 길이 할당
lineNumber = len(line) #라인수 할당
for i in range(digitnumber):
for j in range(lineNumber):
line[j] += ' '+textToGraphic(int(inputNumber[i]), int(j+1))
for j in range(lineNumber):
print line[j]
#문자열이, 숫자(정수/실수)인지, 문자인지 체
def isNumber(s):
try:
float(s)
return True
except ValueError:
print "숫자가 아닌 문자열이 입력 되었습니다."
return False
#입력삽에 범위 검사
def isRange(s, n):
if((1<= int(s) < 10) != True):
print "첫번째 입력된 숫자가 범위를 벗어났습니다."
return False
if((9 < len(n))):
print "두번째 입력된 숫자가 범위를 벗어났습니다."
return False
return True
#입력창
def inputInterface():
arg1 = 1
arg2 = 1
prompt = """
첫번쨰 숫자를 문자을 표시하는 크기( 1<= s < 10 )를 의미
두번째 숫자는 n은 출력될 숫자( 0<= n <= 99,999,999 )를 의미
0 이 두 개 입력된 줄이 있으면 입력이 종료
입력 예
2 12345
3 67890
0 0
Enter nuber : """
while (arg1 != 0 or arg2 != 0) : #종료 조건
print prompt
arg0 = raw_input()
tmp = arg0.split()
if(len(tmp) != 2): #유효성 체크 1
print("문자를 2개 입력하세요")
else :
if(isNumber(tmp[0]) and isNumber(tmp[1])): #유효성 체크 2
arg1 = int(tmp[0])
arg2 = tmp[1]
if(arg1 == 0 and int(arg2) == 0): #while 종료 조건
break;
if(isRange(tmp[0], tmp[1])): #유효성 체크 3
if(arg1!= 0):
global inputNumber
inputNumber = arg2
lcdDisplay(arg1)
inputInterface()
저도 가입기념으로 풀이 하나 달아봅니다.
제 밥벌이인 "델파이"로 만들어 봤습니다.
program CodeJob;
{$APPTYPE CONSOLE}
type
TDigitH = array [0..3-1] of Char;
TDigitHType = (dhN, dhH, dhVA, dhVL, dhVR);
TDigit = array [0..5-1] of TDigitHType;
TDigitChar = '0' .. '9';
const
DigitHTypes: array [TDigitHType] of TDigitH = (
(' ',' ',' '),(' ','-',' '),('|',' ','|'),('|',' ',' '),(' ',' ','|')
);
DigitArray: array [TDigitChar] of TDigit = (
// Digit 0
(dhH, dhVA, dhN, dhVA, dhH),
// Digit 1
(dhN, dhVR, dhN, dhVR, dhN),
// Digit 2
(dhH, dhVR, dhH, dhVL, dhH),
// Digit 3
(dhH, dhVR, dhH, dhVR, dhH),
// Digit 4
(dhN, dhVA, dhH, dhVR, dhN),
// Digit 5
(dhH, dhVL, dhH, dhVR, dhH),
// Digit 6
(dhH, dhVL, dhH, dhVA, dhH),
// Digit 7
(dhH, dhVR, dhN, dhVR, dhN),
// Digit 8
(dhH, dhVA, dhH, dhVA, dhH),
// Digit 9
(dhH, dhVA, dhH, dhVR, dhH)
);
procedure printDigitVLine(aDigit: TDigit; aWidth, aHeight, aVLine: Integer);
var
k,
ii, ij: Integer;
begin
if (aVLine = 0) then ii := 0
else
if (aVLine = aHeight-1) then ii := 4
else
if (aVLine = aHeight div 2) then ii := 2
else
if (aVLine < aHeight div 2) then ii := 1
else ii := 3;
k := 0;
while k < aWidth do
begin
if (k = 0) then ij := 0 else if (k = aWidth-1) then ij := 2 else ij := 1;
Write(DigitHTypes[aDigit[ii]][ij]);
Inc(k);
end;
end;
procedure printDigitStr(const aDigitStr: String; aWidth, aHeight: Integer); overload;
var
i, j: Integer;
begin
for i := 0 to aHeight - 1 do
begin
for j := 1 to Length(aDigitStr) do
begin
printDigitVLine(DigitArray[aDigitStr[j]], aWidth, aHeight, i);
Write(' ');
end;
WriteLn('');
end;
end;
procedure printDigitStr(const aDigitStr: String; aScale: Integer); overload;
begin
if aScale < 1 then Exit;
printDigitStr(aDigitStr, aScale + 2, aScale * 2 + 3);
end;
function StrToIntDef(const S: string; Default: Integer): Integer;
var
E: Integer;
begin
Val(S, Result, E);
if E <> 0 then Result := Default;
end;
procedure FileProc(const aFileName: String);
var
F: TextFile;
S: String;
begin
AssignFile(F, aFileName);
Reset(F);
while not EOF(F) do
begin
Readln(F, S);
if S = '0 0' then Break;
printDigitStr(PChar(@S[3]), StrToIntDef(S[1], 0));
WriteLn('');
end;
CloseFile(F);
end;
procedure AppProc;
var
s: String;
begin
if ParamCount > 0 then
FileProc(ParamStr(1))
else
WriteLn('No input file.'#13#10);
Write('Press any key...');
readln(s);
end;
begin
AppProc;
end.
터보델파이로 빌드하면 22k 나오네요.
원본 텍스트 파일이 다음과 같을 때
input.txt
2 12345
3 67890
0 0
"CodeJob input.txt" 라고 실행시킨 출력결과는 다음과 같습니다.
좋은 사이트 만들어주셔서 감사합니다. 자주 자주 놀러올께요~ ^^;;
ps. 중복된 정보를 조금 털어내서 실행파일 크기를 1k 정도 더 줄여봤습니다.
좀 더 최적화의 여지가 있겠지만... 제 능력은 여기까지 같아요~ ^^;
(수정 전 원본은 http://oranke.tistory.com/190 에)
저도 가입기념으로 복잡하지만, 제 스타일 대로.. ㅡ.ㅡ;
program Sample;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
TextCanvas in 'TextCanvas.pas',
DigitFont in 'DigitFont.pas';
var
DigitFont : TDigitFont;
begin
DigitFont := TDigitFont.Create;
try
DigitFont.FontSize := 1;
DigitFont.WriteDigit('01234');
WriteLn;
DigitFont.FontSize := 2;
DigitFont.WriteDigit('56789');
finally
DigitFont.Free;
end;
Write('Press any key...');
ReadLn;
end.
문제대로 파일을 읽고 등등은 생략 ^^;
문제의 핵심을 폰트 크기와 숫자를 LED 디스플레이로 표시하는 것으로 압축하고,
거기에 해당하는 인터페이스를 가진 클래스 제작.
그리고 실행 결과
TDigitFont 클래스의 중요 소스
procedure TDigitFont.WriteDigit(Digit:string);
const
_FontWidth = 3;
_FontHeight = 5;
var
sFontData : string;
Loop: Integer;
begin
FCanvas.Width := Length(Digit) * (FontSize + 1) * _FontWidth;
FCanvas.Height := FontSize * _FontHeight;
FCanvas.Clear;
for Loop := 0 to Length(Digit)-1 do begin
// 현재 폰트를 찍을 위치로
FCanvas.MoveTo(Loop * (FontSize + 1) * _FontWidth, 0);
// 현재 폰트의 벡터 정보 가져오기
sFontData := _DigitFontData[Ord(Digit[Loop+1]) - Ord('0')];
draw_Digit(sFontData);
end;
FCanvas.Draw;
end;
procedure TDigitFont.draw_Digit(FontData: string);
var
Loop : Integer;
begin
for Loop := 1 to Length(FontData) do begin
case FontData[Loop] of
'l': FCanvas.MoveLeft;
'r': FCanvas.MoveRight;
'd': FCanvas.MoveDown;
'u': FCanvas.MoveUp;
'<': FCanvas.MoveLeft(FontSize);
'>': FCanvas.MoveRight(FontSize);
'.': FCanvas.MoveDown(FontSize);
'^': FCanvas.MoveUp(FontSize);
'L': FCanvas.LineLeft(FontSize);
'R': FCanvas.LineRight(FontSize);
'D': FCanvas.LineDown(FontSize);
'U': FCanvas.LineUp(FontSize);
end;
end;
end;
각 폰트의 벡터 정보를 토대로 폰트를 그린다.
벡터 정보는 아래와 같다.
const
_DigitFontData : array [0..9] of string = (
'dDdDrRuUuUlL', // 0
'rrdDdD', // 1
'rRdDlLdDrR', // 2
'rRdDdDlL^urR', // 3
'dDrR^DdD', // 4
'rR<ldDrRdDlL', // 5
'rLdDrRdDlLuU', // 6
'rRdDdD', // 7
'rRdDlLdDrRuUl<uU', // 8
'd.rLuUrRdDdDlL' // 9
);
위에서 사용되는 TTextCanvas 클래스의 인터페이스 (FCanvas)
type
TTextCanvas = class
private
public
procedure Clear;
procedure MoveTo(X,Y:integer);
procedure MoveLeft(Count:integer = 1);
procedure MoveRight(Count:integer = 1);
procedure MoveDown(Count:integer = 1);
procedure MoveUp(Count:integer = 1);
procedure LineLeft(Count:integer = 1);
procedure LineRight(Count:integer = 1);
procedure LineDown(Count:integer = 1);
procedure LineUp(Count:integer = 1);
procedure Draw;
property X : integer;
property Y : integer;
property Width : integer;
property Height : integer;
end;
아무래도 델파이는 눈에 익지 않으실 듯 해서... C로 바꿔 올려봅니다.
MinGW로 컴파일 해보니 터보델파이 보다 300바이트 정도 작게 나오네요. ^^;;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef char TDigitH [3];
typedef enum {dhN, dhH, dhVA, dhVL, dhVR} TDigitHType;
typedef TDigitHType TDigit [5];
const TDigitH DigitHTypes [] = {
{' ',' ',' '}, {' ','-',' '}, {'|',' ','|'},{'|',' ',' '}, {' ',' ','|'}
};
const TDigit DigitArray [] = {
// Digit 0 // Digit 1
{dhH, dhVA, dhN, dhVA, dhH}, {dhN, dhVR, dhN, dhVR, dhN},
// Digit 2 // Digit 3
{dhH, dhVR, dhH, dhVL, dhH}, {dhH, dhVR, dhH, dhVR, dhH},
// Digit 4 // Digit 5
{dhN, dhVA, dhH, dhVR, dhN}, {dhH, dhVL, dhH, dhVR, dhH},
// Digit 6 // Digit 7
{dhH, dhVL, dhH, dhVA, dhH}, {dhH, dhVR, dhN, dhVR, dhN},
// Digit 8 // Digit 9
{dhH, dhVA, dhH, dhVA, dhH}, {dhH, dhVA, dhH, dhVR, dhH}
};
void printDigitVLine(const TDigit aDigit, int aWidth, int aHeight, int aVLine)
{
int k =0, ii, ij;
int halfHeight = div(aHeight, 2).quot;
if (aVLine == 0) ii = 0; else
if (aVLine == aHeight-1) ii = 4; else
if (aVLine == halfHeight) ii = 2; else
if (aVLine < halfHeight) ii = 1; else
ii = 3;
while (k < aWidth) {
if (k == 0) ij = 0; else if (k == aWidth-1) ij = 2; else ij = 1;
putchar(DigitHTypes[aDigit[ii]][ij]);
k++;
}
putchar(' ');
}
void printDigitStr(char *aDigitStr, int aScale)
{
if (aScale < 1) return;
int i, j;
int Width = aScale + 2;
int Height = aScale * 2 + 3;
for (i=0; i<Height; i++) {
for (j=0; j<strlen(aDigitStr); j++) {
printDigitVLine(DigitArray[aDigitStr[j]-'0'], Width, Height, i);
}
printf("\n");
}
}
void FileProc(char *aFileName)
{
FILE *in;
if (in=fopen(aFileName, "r")) {
int Scale;
char DigitStr[100];
while (0 < fscanf(in, "%d %s", &Scale, &DigitStr)) {
if (Scale == 0 && strcmp(DigitStr, "0") == 0) break;
printDigitStr(DigitStr, Scale);
printf("\n");
}
fclose(in);
} else {
printf("Can't open input file\n");
return;
}
}
int main(int argc, char *argv[])
{
if (argc > 1)
FileProc(argv[1]);
else
printf("No input file\n\n");
printf("Press any key...");
getchar();
return 0;
}
타입명에 T를 붙이는 것과 변수명에 대소문자 섞는 건 델파이를 오래 써온 습관이니 눈감아주시와요.
"CodeJob input.txt" 했을 때 출력화면 입니다.

재미난 퀴즈 다시 한 번 감사드려요~~ 코드잡의 무한한 발전을 기원합니다~~^^;;
ps. 숫자사이에 컬럼 하나를 띄우는 걸 까먹어 수정했습니다, ^^
다양한 언어로 던지라고 하시니, 스크립트 중 제가 제일 좋아라하는 루아도 하나 투척합니다~~ ^^;;
내용은 델파이나 씨로 짠 것과 거의 동일한데...
루아의 콘솔 출력함수인 print() 가 줄단위 출력만 되는 바람에 약간 수정되었네요.
CodeJob.lua
dhN = 1; dhH = 2; dhVA = 3; dhVL = 4; dhVR = 5;
DigitHTypes = {
{' ',' ',' '}, {' ','-',' '}, {'|',' ','|'},{'|',' ',' '}, {' ',' ','|'}
}
DigitArray = {
{dhH, dhVA, dhN, dhVA, dhH}, {dhN, dhVR, dhN, dhVR, dhN},
{dhH, dhVR, dhH, dhVL, dhH}, {dhH, dhVR, dhH, dhVR, dhH},
{dhN, dhVA, dhH, dhVR, dhN}, {dhH, dhVL, dhH, dhVR, dhH},
{dhH, dhVL, dhH, dhVA, dhH}, {dhH, dhVR, dhN, dhVR, dhN},
{dhH, dhVA, dhH, dhVA, dhH}, {dhH, dhVA, dhH, dhVR, dhH}
}
function buildDigitVLine(aDigit, aWidth, aHeight, aVLine)
local k = 0;
local ii, ij;
local halfHeight = math.floor(aHeight/2);
if (aVLine == 0) then ii = 0
elseif (aVLine == aHeight-1) then ii = 4
elseif (aVLine == halfHeight) then ii = 2
elseif (aVLine < halfHeight) then ii = 1
else ii = 3 end;
local str = '';
while (k < aWidth) do
if (k == 0) then ij = 0
elseif (k == aWidth-1) then ij = 2
else ij = 1 end;
str = str .. DigitHTypes[aDigit[ii+1]][ij+1];
k = k + 1;
end;
return str;
end;
function printDigitStr(aDigitStr, aScale)
if (aScale < 1) then return end;
local i, j;
local Width = aScale + 2;
local Height = aScale * 2 + 3;
for i=0, Height-1, 1 do
local outStr = '';
for j=1, string.len(aDigitStr), 1 do
outStr =
outStr ..
buildDigitVLine(
DigitArray[string.byte(aDigitStr,j) - 48 + 1],
Width, Height, i
) .. ' ';
end;
print(outStr);
end;
end;
fh = io.open("input.txt", "r");
while true do
local Scale = fh:read("*n");
local Value = fh:read("*n");
if not Scale then break end;
if (Scale == 0 and Value == 0) then break end;
printDigitStr(tostring(Value), Scale);
end;
fh:close();
CodeJob.lua 파일과 input.txt 를 한 곳에 몰아넣고 루아콘솔에서 dofile("CodeJob") 로 실행한 결과는 다음과 같습니다.

개인적으로는 PHP코드가 올라오면 공부가 많이 될 듯한 소망이 있는데~~
새해 복 많이 받으시고 앞으로도 재미난 문제 많이 내 주세요~~ ^^;;
오랑캐꽃님의 알고리즘을 파이썬으로 바꾸어 보았어요.
파이썬 버전 : 오랑캐꽃님의 알고리즘
import math
dhN = 1; dhH = 2; dhVA = 3; dhVL = 4; dhVR = 5;
DigitHTypes = (
(' ',' ',' '), (' ','-',' '), ('|',' ','|'),('|',' ',' '), (' ',' ','|')
)
DigitArray = (
(dhH, dhVA, dhN, dhVA, dhH), (dhN, dhVR, dhN, dhVR, dhN),
(dhH, dhVR, dhH, dhVL, dhH), (dhH, dhVR, dhH, dhVR, dhH),
(dhN, dhVA, dhH, dhVR, dhN), (dhH, dhVL, dhH, dhVR, dhH),
(dhH, dhVL, dhH, dhVA, dhH), (dhH, dhVR, dhN, dhVR, dhN),
(dhH, dhVA, dhH, dhVA, dhH), (dhH, dhVA, dhH, dhVR, dhH)
)
def printDigitVLine(aDigit, aWidth, aHeight, aVLine):
k = 0
halfHeight = math.floor(aHeight/2)
if aVLine == 0 : ii = 0
elif aVLine == aHeight-1: ii = 4
elif aVLine == halfHeight: ii = 2
elif aVLine < halfHeight: ii = 1
else: ii = 3
result = []
while k < aWidth:
if k == 0: ij = 0
elif k == aWidth-1: ij = 2
else: ij = 1
result.append(DigitHTypes[aDigit[ii]-1][ij])
k += 1
print "".join(result),
def printDigitStr(aDigitStr, aScale):
if aScale < 1: return
Width = aScale + 2
Height = aScale * 2 + 3
for i in range(0, Height):
for j in range(0, len(aDigitStr)):
printDigitVLine(DigitArray[int(aDigitStr[j])], Width, Height, i)
print "\n",
for line in open("input.txt"):
if not line: break
Scale, Value = line.split()
if Scale == "0" and Value == "0": break
printDigitStr(Value, int(Scale))
Ruby 로 놀다 갑니다..
$img = [ "TBtLbRbLtR", "tRbR", "TMBtRbL", "TBMtRbR", "tLtRMbR",
"TBMtLbR", "MBTtLbRbL", "TtRbR", "TBMtLtRbLbR", "TBMtRbRtL" ]
def get_number_string( scale, num )
def get_c( c, flag, char )
$img[c.to_i].include?(flag) ? char : " "
end
r = ""
num.each_char { |c| r += " #{get_c(c, 'T', '-')*scale} " }
r += "\n"
t = ""
num.each_char { |c| t += "#{get_c(c, 'tL', '|')+' '*scale+get_c(c, 'tR', '|')+' '}" }
r += ( t + "\n" ) * scale
num.each_char { |c| r += " #{get_c(c, 'M', '-')*scale} " }
r += "\n"
t = ""
num.each_char { |c| t += "#{get_c(c, 'bL', '|')+' '*scale+get_c(c, 'bR', '|')+' '}" }
r += ( t + "\n" ) * scale
num.each_char { |c| r += " #{get_c(c, 'B', '-')*scale} " }
r += "\n\n"
end
while true do
n1, n2 = STDIN.readline.chomp.split( " " )
break if n1.to_i < 1 or n1.to_i >= 10 or n2.to_i < 0 or n2.to_i > 99999999
puts get_number_string( n1.to_i, n2 )
end

ps. 여기선 루비 스트링 하이라이팅이 제대로 안되는군요. 흠 ;
Testors님의 Ruby를 C++로 바꿔서 올려봅니다.
아무래도 Ruby처럼 깔끔하지는 않네요;;
#include <stdio.h>
#include <tchar.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <conio.h>
char img[] = { 0x77, 0x24, 0x5d, 0x6d, 0x2e, 0x6b, 0x7b, 0x27, 0x7f, 0x6f };
char get_c( int num, int flag, char match )
{
return ( ( img[num] & flag) == flag ) ? match : ' ';
}
std::string horz( int scale, const std::vector <int>& nums, int flag )
{
std::string str;
std::for_each( nums.begin(), nums.end(), [&]( char num )
{
str += ' ';
for ( int i = 0; i < scale; ++i )
str += get_c( num, flag, '-' );
str += ' ';
}
);
str += '\n';
return str;
}
std::string vert( int scale, const std::vector <int>& nums, int flagl, int flagr )
{
std::string str, vert;
std::for_each( nums.begin(), nums.end(), [&]( char num )
{
vert += get_c( num, flagl, '|' );
for ( int i = 0; i < scale; ++i )
vert += ' ';
vert += get_c( num, flagr, '|' );
}
);
for ( int i = 0; i < scale; ++i )
str += vert + '\n';
return str;
}
std::string get_num_string( int scale, const std::vector <int>& nums )
{
std::string str;
str += horz( scale, nums, 0x01 );
str += vert( scale, nums, 0x02, 0x04 );
str += horz( scale, nums, 0x08 );
str += vert( scale, nums, 0x10, 0x20 );
str += horz( scale, nums, 0x40 );
str += "\n\n";
return str;
}
int _tmain(int argc, _TCHAR* argv[])
{
int s;
std::string num_str;
while ( true )
{
std::cin >> s;
std::cin >> num_str;
if ( s == 0 && num_str[0] == '0' )
break;
std::vector <int> nums;
std::transform( num_str.begin(), num_str.end(), std::back_inserter( nums ), [] ( char c ) { return c - '1' + 1; } );
std::cout << get_num_string( s, nums );
}
return 0;
}
<?
/*
---0
|1 |2
---3
|4 |5
---6
*/
// number-index array
$number_a = array(
array(1, 1, 1, 0, 1, 1, 1), // 0
array(0, 0, 1, 0, 0, 1, 0), // 1
array(1, 0, 1, 1, 1, 0, 1), // 2
array(1, 0, 1, 1, 0, 1, 1), // 3
array(0, 1, 1, 1, 0, 1, 0), // 4
array(1, 1, 0, 1, 0, 1, 1), // 5
array(1, 1, 0, 1, 1, 1, 1), // 6
array(1, 0, 1, 0, 0, 1, 0), // 7
array(1, 1, 1, 1, 1, 1, 1), // 8
array(1, 1, 1, 1, 0, 1, 1) // 9
);
$inputfile = file('input.txt');
foreach ($inputfile as $line) {
$l_e = explode(' ', $line);
if($l_e[0]==0 && $l_e[1]==0) {
break;
}
$s_length = $l_e[0];
$number_string = $l_e[1];
$number_string_count = strlen($number_string);
$line_s = array();
for($j=0;$j<$number_string_count;$j++) {
$n_a = $number_a[$number_string[$j]];
if($n_a)foreach($n_a as $ln => $n) {
if($ln==0 || $ln==3 || $ln==6) {
$line_str = '-';
} else {
$line_str = '|';
}
if($n!=1) {
$line_str = ' ';
}
// index 값
if($ln==0 || $ln==1) {
$index = $ln;
} else if($ln==3 || $ln==4) {
$index = $ln+$s_length;
} else if($ln==2) {
$index = $ln-1;
} else if($ln==5) {
$index = $ln-1+$s_length;
} else if($ln==6) {
$index = ($ln-1)+($s_length*2);
} else {
}
switch($ln) {
case 0 :
case 3 :
case 6 :
$line_s[$index].= ' '.str_repeat($line_str, $s_length).' ';
break;
case 1 :
case 4 :
case 2 :
case 5 :
for($i=$index;$i<$index+$s_length;$i++) {
if($ln==2 || $ln==5) {
$l_str = ' ';
} else {
$l_str = '';
}
$line_s[$i].= $line_str.$l_str;
if($ln==1 || $ln==4) {
$line_s[$i].= str_repeat(' ', $s_length);
}
}
break;
default :
break;
}
}
}
foreach($line_s as $ln => $n) {
echo $n."\n";
}
echo "\n";
}
?>

오류 검사부분은 완전히 배제했습니다. >.<
평소에 생각해보지 않았는데 은근히 힘드네요.
함수 배제하고 for 문을 남발한게 좀 그렇긴 하지만 좋은 공부 된것 같습니다. ㄳ
오랜만에 파이썬을 써봐서 그다지 적절하지 못한 코드가 나왔습니다. 요점은 함수적으로 작성하려고 노력했다는 것이지만 나온 결과는 개떡 같은 코드가 되었습니다. 혹시나 파이썬을 접하지 못한 분들께 오해를 불러올까봐 노파심에 한 마디 해야 할 것 같은데, 대부분의 파이썬 코드는 훨씬 깨끗하고 이해하기 쉬운 코드랍니다.
루비 같은 언어였으면 코드 골프질을 하는 것도 재미있었을 것 같군요.
수정: 간만에 쓰니까 존재를 까먹은 함수들이 많네요. 좀 더 정상적인 코드로 수정을 해보았습니다.
def digit(size, number):
def h(c): return ' ' + c * size + ' \n'
def v(l, r): return (l + ' ' * size + r + '\n') * size
def c(bit): return '-||-||-'[bit] if [119, 18, 93, 91, 58, 107, 111, 82, 127, 123][number] & 2**bit else ' '
return h(c(6)) + v(c(5), c(4)) + h(c(3)) + v(c(2), c(1)) + h(c(0))
def digits(size, input):
return '\n'.join(map(lambda x: ' '.join(x),
zip(*map(lambda n: digit(size, n).split('\n')[:-1], input))
))+'\n' if size > 0 else ''
print(digits(2, [1, 2, 3, 4, 5]))
print(digits(3, [6, 7, 8, 9, 0]))
print(digits(0, [0]))
사람들이 좋아하는 코드를 짤 능력은 없지만, 골프 코드를 모두 즐겨 보았으면 해서 이 글타래에서 가장 인기 있어 보이는 델파이로 아라크넹 님의 코드를 번역해 보았습니다. (루비 코드는 도무지 해독이 안됩니다!)
가능한 원래 코드의 의도를 살리려고 하였고 언어의 한계로 직역이 불가능한 부분은 흐름을 해치지 않도록 손봤습니다.
먼저 번역하기 위해 수정한 파이썬 코드입니다.
p=1
while p:
p,q=raw_input().split();p=int(p)
if p:
for x in[28728]+[240145116382356]*p+[481051017279]+[240144847283604]*p+[246298135523384,-1]: # 7-segment row magic keys
sc = ' - | | ' # 7-segment column
for j in q:
di = (x >> (int(j, 16) * 3)) &7
print sc[di+1] + sc[di+2]*p + sc[di+3] + ' ',
print ''
리스트 제너레이터와 문자열 조인을 떼고 나니 코드가 눈에 조금 들어오기 시작합니다. 서브스트링은 파이썬과 달리 쉽지 않으니 인덱스로 대체했습니다.
리스트 곱은 상황에 따라 다른 기교로 처리해야 할 것 같으므로 일단 두었습니다. 공백문자 출력이 원본과 다르겠지만 눈에는 똑같이 보이므로 따로 처리하지 않습니다.
번역한 파스칼 코드입니다. 윈도를 사용하지 않기 때문에 불가피하게 프리파스칼을 쓰게 되었습니다.
for in 루프를 지원하는 델파이에서 아마 문제 없이 컴파일 되리라 생각합니다.
type tx = Array[0..1] of LongInt;
const
xx: Array[1..6] of tx = ((28728, 1), (609961108, 0), (14680127, 1), (340862356, 0), (14708792, 1), (-1, 1)); // magic keys for each row of 7-segment
sc = ' - | | '; // 7-segment strings
var
i,ii,di,p:Integer;
q:String;
j:char;
x:tx;
begin
p := 1;
while p > 0 do begin
readln(p, j, q); // dump out space j
if p > 0 then begin
xx[2][1] := p; xx[4][1] := p; // set row length ( list*p in python )
for x in xx do for i := 1 to x[1] do begin // for x in ... loop
for j in q do begin // for j in q generator
di := x[0] shr ((ord(j) - 48) * 3) and 7;
// verbose print for ' '.join
write(sc[di+1]);
for ii := 1 to p do write(sc[di+2]);
write(sc[di+3], ' ')
end;
writeln
end
end
end
end.
변수를 최대한 파이썬 코드와 일치하게 맞췄습니다.
for x in 루프의 리스트 곱을 흉내내기 위해 루프 하나를 더 도입하고 x를 배열로 만든 것 외에는 수정한 파이썬 코드를 거의 그대로 옮겼습니다.
해독은 각자 즐길 수 있는 재미라고 생각하여 언어 상의 차이 외엔 전혀 손대지 않으려고 노력하였습니다.
실행하면...

원래 코드처럼 나옵니다
작업 후 덤으로, 저는 골퍼는 아니지만 원본이 골프였는 만큼 나름 줄이려고 노력은 해보았습니다.
const
y:Array[1..6]of
Int64=(28728,609961108,$e0003f,340862356,$e07038,-1);S=' - | | ';var
g,i,k,d,p:Word;q:String;j:char;
begin
p:=1;while p>0do
begin
readln(p,j,q);if p>0then
begin
for g:=1to 6do begin
i:=1;if g in[2,4]then i:=p;for i:=1to i do
begin
for j in q do
begin
d:=y[g]shr(ord(j)*3-144)and 7;write(S[d+1]);for k:=1to p do write(S[d+2]);write(S[d+3],' ')
end;writeln
end
end
end
end
end.
그래도 400바이트입니다. 골프 기교와 언어에 대한 이해가 모두 부족해서겠지만 더 이상은 못줄이겠네요.
파스칼로 파이썬 코드 두배 정도면 선방한 셈이라 생각합니다 :)
프리파스칼 확장을 이용하면 2바이트 더 줄일 수 있습니다.
const
y:Array[1..6]of
Int64=(28728,609961108,$e0003f,340862356,$e07038,-1);S=' - | | ';var
g,i,k,d,p:Word;q,b:String;j:char;
begin
p:=1;while p>0do
begin
readln(p,j,q);if p>0then
begin
for g:=1to 6do begin
i:=1;if g in[2,4]then i:=p;for i:=1to i do
begin
b:='';for j in q do
begin
d:=y[g]>>(ord(j)*3-144)and 7;b+=S[d+1];for k:=1to p do b+=S[d+2];b+=S[d+3]+' '
end;writeln(b)
end
end
end
end
end.
덕분에 재미있었습니다 감사합니다.
Perl 코드가 없어 leonid옹의 코드를 보고 간단히 만들어 봅니다.
chomp;/ /;exit if(!$` && !$');if($`&&$'>=0&&$'<=99999999){
foreach$l(28728,609961108,14680127,340862356,14708792){
$r="";foreach(split//,$'){$k=substr(' - | | ',7&$l>>$_*3,4);
substr($k,1,1,substr($k,1,1)x$`);$r.=$k;}print+($r."\n")x($l%7<1?1:$`);}}
저는 아라크넹옹이나 leonid옹처럼 코드골프를 하는 사람이 아니라서 충분히 최적화(?)를 하지 못했는데 다른 분들의 조언을 듣고 싶네요.

252바이트인데요. Ruby나 Python 코드처럼 조건을 체크하지 않으면 아래와 같은 코드이고 211바이트입니다.
chomp;/ /;if($`){foreach$l(28728,609961108,14680127,340862356,14708792)
{$r="";foreach(split//,$'){$k=substr(' - | | ',7&$l>>$_*3,4);substr($k,1,
1,substr($k,1,1)x$`);$r.=$k;}print+($r."\n")x($l%7<1?1:$`);}}
common lisp 으로 만들어 봤습니다.
(defparameter *number-def*
(make-array 10 :initial-contents
'((H LR nil LR H)
(nil R nil R nil)
(H R H L H)
(H R H R H)
(nil LR H R nil)
(H L H R H)
(H L H LR H)
(H R nil R nil)
(H LR H LR H)
(H LR H R nil))))
(defun transpose (x)
(apply #'mapcar (cons #'list x)))
(defun make-print-data (lst scale)
(flet ((s (node)
(cond ((eq node 'H) (append '(nil) (make-list scale :initial-element 'hipen) '(nil)))
((eq node 'LR) (append '(bar) (make-list scale) '(bar)))
((eq node 'L) (append '(bar) (make-list (1+ scale))))
((eq node 'R) (append (make-list (1+ scale)) '(bar)))
(t (make-list (+ scale 2))))))
(loop for line in (mapcar (lambda (x)
(mapcar #'s x))
lst)
for i from 0
collect line
when (equal (rem i 2) 1)
append (loop repeat (1- scale) collect line))))
(defun print-symbol (output ss colon-p at-p)
(princ (coerce
(mapcar (lambda (x)
(cond ((eq x 'hipen) #\-)
((eq x 'bar) #\|)
(t #\space)))
ss)
'string)
output))
(defun print-line (lst)
(format t "~{~{~/print-symbol/ ~}~%~}~%" lst))
(defun process-line (line)
(multiple-value-bind (scale pos) (read-from-string line)
(let ((data (map 'list
(lambda (x)
(- (char-code x) (char-code #\0)))
(subseq line pos))))
(print-line (make-print-data (transpose (mapcar (lambda (x)
(aref *number-def* x))
data))
scale)))))
(defun read-loop (is)
(do ((line (read-line is nil)
(read-line is nil)))
((or (null line)
(equal (string-trim '(#\space #\tab #\newline) line) "0 0"))
nil)
(process-line line)))
(defun main ()
(fresh-line)
(read-loop *standard-input*))
mac 에서 clozure lisp 으로 실행시킨 결과입니다.

자바 좀더 짧은 버전입니다.
import java.io.*;
public class Main {
public static int nFlags[] = {0x77, 0x12, 0x5D, 0x5B, 0x3A, 0x6B, 0x6F, 0x52, 0x7F, 0x7A, 0x00};
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader("C:\\test.txt"));
String line;
while((line = reader.readLine()) != null) {
String[] arr = line.split(" ");
int[] narr = new int[arr[1].length()];
for(int i=0; i<arr[1].length(); i++)
narr[i] = arr[1].charAt(i) - 0x30;
printNumbers(narr, Integer.parseInt(arr[0].trim()));
}
}
public static void printNumbers(int[] num, int pc) {
for(int i=1; i<=5; i++) {
if(i%2==0)
for(int k=0; k<pc; k++) {
for(int j=0; j<num.length; j++) {
System.out.print(((nFlags[num[j]] >> (int)((5-i)*1.5)+1)&0x01)==1?'|':' ');
for(int l=0; l<pc; l++)
System.out.print(' ');
System.out.print((((nFlags[num[j]] >> (int)((5-i)*1.5))&0x01)==1?'|':' ')+" ");
}
System.out.println();
}
else {
for(int j=0; j<num.length; j++) {
System.out.print(' ');
for(int l=0; l<pc; l++)
System.out.print(((nFlags[num[j]] >> (int)((5-i)*1.5))&0x01)==1?'-':' ');
System.out.print(" ");
}
System.out.println();
}
}
}
}
스크립트 계열 언어들 대단하군요. 골프 기교 처음봅니다.
누군가가 자바도 골프에 가까운 기교를 한번 구현해서 올려보길 기대해봅니다.
무식한 방법밖에 생각이 안 나네요.
#include <stdio.h>
#include <string.h>
/*
* Seven segment display index
* ----0----
*| |
*1 2
*| |
* ----3----
*| |
*4 5
*| |
* ----6----
*/
char seven_segment[10][7] = {
{'-', '|', '|', ' ', '|', '|', '-'}, // 0
{' ', ' ', '|', ' ', ' ', '|', ' '}, // 1
{'-', ' ', '|', '-', '|', ' ', '-'}, // 2
{'-', ' ', '|', '-', ' ', '|', '-'}, // 3
{' ', '|', '|', '-', ' ', '|', ' '}, // 4
{'-', '|', ' ', '-', ' ', '|', '-'}, // 5
{'-', '|', ' ', '-', '|', '|', '-'}, // 6
{'-', ' ', '|', ' ', ' ', '|', ' '}, // 7
{'-', '|', '|', '-', '|', '|', '-'}, // 8
{'-', '|', '|', '-', ' ', '|', '-'} // 9
};
void print_repeatly(char ch, int n)
{
while (n--) {
printf("%c", ch);
}
}
int char_to_int(char ch)
{
switch (ch) {
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
default : return -1;
}
}
void print_digit(int s, const char *digit, int n)
{
int i, j;
for (i = 0; i < 2 * s + 3; i++) {
for (j = 0; j < n; j++) {
char ch;
if (i == 0) {
printf(" ");
print_repeatly(seven_segment[char_to_int(digit[j])][0], s);
printf(" ");
} else if (i < s + 1) {
printf("%c", seven_segment[char_to_int(digit[j])][1]);
print_repeatly(' ', s);
printf("%c", seven_segment[char_to_int(digit[j])][2]);
} else if (i == s + 1) {
printf(" ");
print_repeatly(seven_segment[char_to_int(digit[j])][3], s);
printf(" ");
} else if (i < 2 * s + 2) {
printf("%c", seven_segment[char_to_int(digit[j])][4]);
print_repeatly(' ', s);
printf("%c", seven_segment[char_to_int(digit[j])][5]);
} else {
printf(" ");
print_repeatly(seven_segment[char_to_int(digit[j])][6], s);
printf(" ");
}
printf(" ");
}
printf("\n");
}
}
int main(int argc, char *argv[])
{
int s;
char digit[9];
while (scanf("%d %s", &s, digit)) {
if (s == 0) break;
print_digit(s, digit, strlen(digit));
}
return 0;
}
Scala로 작성해 보았습니다. 인덴트 다 없애고 세미콜론으로 분리해 한 줄로 만들면 472바이트까지 나옵니다.
object L extends App{
def r(a:Seq[String]):Unit=Console.readLine match{
case"0 0"=>a.foreach(_ split' 'match{case Array(t,q)=>
val p=t.toInt
def m[A](a:A,n:Int=p)=Vector.fill(n)(a)
(m("",2*p+3)/:q.map{c=>
val b=Seq.tabulate(7)(Seq(119,36,93,109,46,107,123,37,127,111)(c-48)>>_&1)
def h(i:Int)=' '+:m(" -"(b(i))):+' '
def v(i:Int,j:Int)=m(" |"(b(i))+:m(' '):+" |"(b(j)))
h(0)+:v(1,2)++:h(3)+:v(4,5):+h(6)
})(_ zip _ map{case(x,y)=>x++y})foreach println
})
case s=>r(a:+s)
}
r(Nil)
}
코드를 짧게 작성하기 위해서 실제로는 비효율적인 부분들이 있습니다. Vector대신 Seq를 쓴다든가, 리스트의 맨 뒷부분에 데이터를 추가한다든가 하는 만행(?)이 포함되어 있습니다.
결과는 다음과 같습니다.
2 12345
3 67890
0 0
-- -- --
| | || ||
| | || ||
-- -- -- --
|| | | |
|| | | |
-- -- --
--- --- --- --- ---
| || || || |
| || || || |
| || || || |
--- --- ---
| | || | || |
| | || | || |
| | || | || |
--- --- --- ---
python 3.x
tbl = ('1110111',
'0010010',
'1011101',
'1011011',
'0111010',
'1101011',
'1101111',
'1010010',
'1111111',
'1111011');
def digitToStringLine(altitude, digit, s):
t = tbl[int(digit)]
F = lambda i : t[i] == '1'
if 0 == altitude:
return F(0) and (' ' + '-'*s + ' ') or (' '*(s+2))
if altitude <= (s):
return (F(1) and '|' or ' ') + ' '*s + (F(2) and '|' or ' ')
if altitude == (1+s):
return F(3) and (' ' + '-'*s + ' ') or (' '*(s+2))
if altitude <= (1+s*2):
return (F(4) and '|' or ' ') + ' '*s + (F(5) and '|' or ' ')
return F(6) and (' ' + '-'*s + ' ') or (' '*(s+2))
def numToStringLine(altitude, snum, s):
l = [digitToStringLine(altitude, c, s) for c in snum]
return ' '.join(l)
def LCD(s, num):
snum = str(num)
l = [numToStringLine(i,snum,s) for i in range(3+s*2)]
return '\n'.join(l)
def display(lines):
lines = lines.strip().split('\n')
for l in lines:
l = l.split()
s = int(l[0])
n = int(l[1])
if s == 0:
print('good bye')
break;
print(LCD(s,n))
l = '''
2 12345
3 67890
0 0
'''
display(l)
while True:
s,n = raw_input().split(' ')
s = int(s)
if s is 0 and n is '0':
break
#floor5
for i in n:
print '',
if i is '1' or i is '4':
print ' '*s,
else:
print '-'*s,
print '',
print ''
#floor4
for i in range(s):
for j in n:
if j is '0' or j is '4' or j is '8' or j is '9':
print '|'+' '*s+'|',
elif j is '5' or j is '6':
print '|'+' '*s+' ',
else:
print ' '+' '*s+'|',
print ''
#floor3
for i in n:
print '',
if i is '1' or i is '7' or i is '0':
print ' '*s,
else:
print '-'*s,
print '',
print ''
#floor2
for i in range(s):
for j in n:
if j is '6' or j is '8' or j is '0':
print '|'+' '*s+'|',
elif j is '2':
print '|'+' '*s+' ',
else:
print ' '+' '*s+'|',
print ''
#floor1
for i in n:
print '',
if i is '1' or i is '4' or i is '7':
print ' '*s,
else:
print '-'*s,
print '',
print ''
// java
public class LcdDisplay {
public static void main(String[] args) {
lcd(3, "0123456789");
}
public static void lcd(int size, String digits) {
int nums[] = {0x77,0x24,0x5d,0x6d,0x2e,0x6b,0x7a,0x27,0x7f,0x2f};
for(int row=0; size>0 && row<size*2+3; row++)
for(int digit=0; digit<digits.length(); digit++){
int n = digits.charAt(digit) - '0';
for(int col=0; col<size+2; col++)
if(row%(size+1)==0 && col%(size+1)!=0 && (nums[n]&(1<<(row/(size+1)*3)))!=0)
System.out.print("-");
else if(row%(size+1)!=0 && col%(size+1)==0
&& (nums[n]&(1<<((row/(size+1)*3+col/(size+1)+1))))!=0)
System.out.print("|");
else
System.out.print(" ");
System.out.print(digit==digits.length()-1 ? "\n" : " ");
}
}
}
프로그래밍을 배운지 1년 반 조금 넘은 고등학생입니다! c++로 for문이 많은 지저분한 소스에요.... ㅠㅠ 그래도 100줄은 안넘겨서 다행입니다.
#include <iostream>
using namespace std;
int getNumLength(int);
int* getNumInfo(int);
void printNum(int, int);
int numInfo[10][7] =
{
{1,1,1,0,1,1,1},
{0,0,1,0,0,1,0},
{1,0,1,1,1,0,1},
{1,0,1,1,0,1,1},
{0,1,1,1,0,1,0},
{1,1,0,1,0,1,1},
{1,1,0,1,1,1,1},
{1,0,1,0,0,1,0},
{1,1,1,1,1,1,1},
{1,1,1,1,0,1,1}
};
char numChar[3] =
{
' ',
'|',
'-'
};
int main(int argc, const char * argv[])
{
printNum(4321, 3);
}
int getNumLength(int num)
{
int count = 0;
while(num)
{
num/=10;
count++;
}
return count;
}
int* getNumInfo(int num)
{
int *numPosition = new int;
numPosition[0] = getNumLength(num);
int count = 0;
while(num) {
numPosition[numPosition[0]-count] = num%10;
num/=10;
count++;
}
return numPosition;
}
void printNum(int num, int size)
{
int *numberInfo = getNumInfo(num);
int temp = 0;
for(int i = 0; i < 5; i++) {
if (i % 2 == 0) {
for(int numberSize = 1; numberSize <= numberInfo[0]; numberSize++) {
cout << ' ';
for(int j = 0; j < size; j++)
cout << numChar[numInfo[numberInfo[numberSize]][temp]*2];
cout << " ";
}
cout<<endl;
temp++;
} else {
for(int j = 0; j < size; j++) {
for(int numberSize = 1; numberSize <= numberInfo[0]; numberSize++) {
cout << numChar[numInfo[numberInfo[numberSize]][temp]];
for(int k = 0; k < size; k++)
cout << ' ';
cout << numChar[numInfo[numberInfo[numberSize]][temp+1]];
cout << ' ';
}
cout << endl;
}
temp+=2;
}
}
}
JAVA로 만들어 봤습니다... Python을 따라갈 수 없네요 ㅡ.,ㅡ
public class Display {
int bitmap[]={151290433,340862164,151294528,609076372,153387585},
repeat[]={1,1,1,1,1};
String str[]={" "," - "," |","| ","| |"}, space;
public void show(int numbers[], int size){
int i, line, r, rr, idx;
for(line=4,repeat[1]=size,repeat[3]=size ; line>=0 ; line--){
for(r=0;r<repeat[line];r++){
for(i=0;i<numbers.length;i++){
idx = (int)(bitmap[line]/Math.pow(8, numbers[i])) &7;
for(space="",rr=0;rr<size;rr++) space+=str[idx].charAt(1);
System.out.print(" "+str[idx].charAt(0)+space+str[idx].charAt(str[idx].length()-1));
}
System.out.println();
}
}
}
public static void main(String[] args) {
int input[]={0,1,2,3,4,5,6,7,8,9},
size=7;
new Display().show(input,size);
}
}
python 3.4.1 입니다
s = 4
n = '0123456789'
t=int('2SQLUF5YMT3AOIA4WEGWHIXJZ6IY3MT1OWP8OFMR55EPI642MVCJ1MD5S4',36)
for y in[0]+[1]*s+[2]+[3]*s+[4]:
print(' '.join([''.join([' -|'[(t>>(30*int(d)+6*y+2*x))&3]for x in[0]+[1]*s+[2]])for d in n]))
---- ---- ---- ---- ---- ---- ---- ----
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
---- ---- ---- ---- ---- ---- ----
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
---- ---- ---- ---- ---- ---- ----
C#으로 작성했습니다. 어려운 문제는 아니었으나, 위에 python 답을 보니 왠지 매우 부끄럽네요.
public string[] GetLCD(int n, string input)
{
var row = n*2 + 3;
var outputs = new string[input.Length];
for (int i = 0; i < input.Length; i++)
{
var curr = input[i].ToString();
for (int j = 0; j < row; j++)
{
if (j == 0 || j == row - 1)
{
if (curr == "1" || curr == "4" || (j == row - 1 && curr == "7"))
{
outputs[i] += "\n";
continue;
}
outputs[i] += " " + string.Empty.PadLeft(n).Replace(" ", "-") + " ";
}
else if (j == n + 1)
{
if (curr == "1" || curr == "7" || curr == "0")
{
outputs[i] += "\n";
continue;
}
outputs[i] += " " + string.Empty.PadLeft(n).Replace(" ", "-") + " ";
}
else if (j < n + 1)
{
outputs[i] += curr == "1" || curr == "2" || curr == "3" || curr == "7" ? " " : "|";
outputs[i] += string.Empty.PadLeft(n);
outputs[i] += curr == "5" || curr == "6" ? " " : "|";
}
else
{
outputs[i] += curr == "2" || curr == "6" || curr == "8" || curr == "0" ? "|" : " ";
outputs[i] += string.Empty.PadLeft(n);
outputs[i] += curr == "2" ? " " : "|";
}
outputs[i] += "\n";
}
}
return outputs;
}
package FirstPac;
/**
* Created by 402-02 on 2014-12-18.
*/
class NumCat {
int[] numSet = new int[10];
public NumCat() {
numSet[0] = 1003130;//가장 높은 수가 0이면 진법을 바꿔서 10을 앞에 붙임. 5자리까지만 사용해서 문제는 없음
numSet[1] = 1012121;//setDigNum에 저장된 문자열을 불러오기 위한 번호를 출력 순서로 저장
numSet[2] = 1004020;//출력순서는 1의 자리부터 뽑아 쓰므로 역순으로 작성
numSet[3] = 1002020;
numSet[4] = 1012031;
numSet[5] = 1002040;
numSet[6] = 1003040;
numSet[7] = 1012120;
numSet[8] = 1003030;
numSet[9] = 1002030;
}
private int temp=0;
// numSet은 Digit에서 하나의 숫자가 구성되는 세트를 만들어 둔다.1~9
public int getNum(int num,int a){
int ten=1;
for(int j=2; j<=a;j++){
//받아온 수 a가 1일 경우는 실행되면 10의 자리를 가져가기 때문에
//받아온 수가 a일 때는 실행되지 않게 한다.
ten = ten * 10;
}
temp = ((numSet[num]/ten)%10);
return temp;
}
}
package FirstPac;
/**
* Created by 402-02 on 2014-12-18.
*/
class StringInit { //String Initialize String 배열초기화
private String[] setDigNum = new String[5];
StringInit(int num) {
for (int i = 0; i<3;i++) {
setDigNum[i] = " ";
}
setDigNum[4] = "|";
setDigNum[3] = "|";
for (int i = 1; i <= num; i++) {
setDigNum[0] = setDigNum[0] + "-"; //setDigNum[0] = " ----"
setDigNum[1] = setDigNum[1] + " "; //1 = " "
setDigNum[2] = setDigNum[2] + " "; //2 = " "
setDigNum[3] = setDigNum[3] + " "; //3 = "| "
setDigNum[4] = setDigNum[4] + " "; //4 = "| "
}
setDigNum[0] = setDigNum[0] + " "; //setDigNum[0] = " ---- "
setDigNum[1] = setDigNum[1] + " "; //1 = " "
setDigNum[2] = setDigNum[2] + "|"; //2 = " |"
setDigNum[3] = setDigNum[3] + "|"; //3 = "| |"
setDigNum[4] = setDigNum[4] + " "; //4 = "| "
}
public String getNumStr(int n) {
return setDigNum[n];
}
}
package FirstPac;
import java.util.Scanner;
/**
* Created by 402-02 on 2014-12-18.
*/
/** NumCat은 번호를 DIGT형태로 정의해주는 클래스
* StringInit는 DIGIT형 숫자의 각행의 문자열을 정의 해주는 클래스
*/
public class FirstTest {
public static void main(String[] args) {
//각 배열당 경우의 수를 저장
Scanner inputNum = new Scanner(System.in);
int valOfSize = 0; // DIGITAL NUMBE 의 각 선을 구성하는 칸을 지정하여 받을 변수
int tempNum = 0; // DIGIT 로 전환 할 숫자를 받아 놓고 사용할 변수
int[] tempNum2 = new int[9];// tempNum을 각 자리수 마다 저장할 변수
for(int i=0; i<=8; i++)
{
tempNum2[i] = 0;
} // tempNum2의 각 배열을 초기화
System.out.print("이 프로그램은 입력된 숫자를 LED형식으로 출력합니다." +
"\n한 선의 길이를 정해주세요\n");
do {
System.out.println("최소 1 최대 10의 크기를 가질 수 있습니다.");
valOfSize = inputNum.nextInt();
} while (1 <= valOfSize ^ valOfSize <= 10); //너무 크거나 작은 수를 받으면 값을 다시 받도록 do while로 제어(한번은 무조건 실행)
System.out.println("자연수를 입력해주세요");
tempNum = inputNum.nextInt();
// tempNum2[8] = tempNum%10; //1의 자리. 1의 자리는 수식으로 처리할경우 0이 연산 오류를 출력하기 때문에 별도로 입력
//// System.out.println(tempNum%10); //계산 결과 확인
int tempS = 1;
for(int i=8; i>=0; i--){ /** 1의 자리 부터 처리 하기 때문에 출력값은 1자리 부터
*10,100순서로 나오게 되기 때문에 배열에는 역순으로 저장
*ex) [0]-1자리 [1]10자리 즉 13일 경우 31이 나오게 되는 걸 13이 나오게 처리
*-- 입력이 아니라 출력을 역순으로 하는 방법도 있음--*/
tempNum2[i]=(tempNum/tempS)%10; // 각 자리수를 각 배열로 1자리씩 저장
//ex) 1234/10 = 123%10=3
tempS = tempS * 10; //다음 자리수를 구하기 위하여 자리수 올림
}
// for(int i=0; i<=8;i++){
// System.out.print(tempNum2[i]);
// } //tempNum2의 배열 저장 상태 확임
for(int i=0;i<=8;i++){
if (tempNum2[i]!=0) {
tempS = i;
break;
} //몇자리 수인지를 확인 하여 자리수를 저장하는 문장
}
System.out.println();
StringInit numTstr = new StringInit(valOfSize);
// for(int i=0; i<=4; i++) {
// System.out.println("'" + numTstr.getNumStr(i) + "'");
// } // String 초기화 확인 코드
NumCat gettingNumCode = new NumCat();
int[] getmain = new int[10];
for(int i=1; i<=5; i++) {
if(i==2 || i==4){
for (int k=1; k<=valOfSize; k++) {
for(int j=tempS; j<=8; j++) {
System.out.print(numTstr.getNumStr(gettingNumCode.getNum(tempNum2[j], i)) + " ");
}
System.out.println();
}
}
/** i 가 2인 경우와 4인 경우는 세로획을 늘려야 되는 경우이기 때문에
* 내부에 추가적으로 2중 for문이 쓰게 된다.
* 가로는 String 선언부에서 valOfSize 만큼 입력이 되었고
* 여기서도 valOfSize만큼 똑같은 부분을 출력하고 줄을 바꾸게만들어둔다.
* j의 시작지점이 tempS인 이유는 1의 자리수가 8이기 때문에 위에서 받은 숫자의
* 시작지점인 tempS부터 시작하는 것이다.
*/
else {
for(int j=tempS; j<=8; j++) {
System.out.print(numTstr.getNumStr(gettingNumCode.getNum(tempNum2[j], i)) + " ");
}
}
if(i==3 || i==1){System.out.println();}
} //DIGIT 출력 구문
}
}
결과창
이 프로그램은 입력된 숫자를 LED형식으로 출력합니다.
한 선의 길이를 정해주세요
최소 1 최대 10의 크기를 가질 수 있습니다.
5
자연수를 입력해주세요
74929584
----- ----- ----- ----- ----- -----
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
----- ----- ----- ----- ----- ----- -----
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
----- ----- ----- ----- -----
자바로 짜보았지만 무려 150줄이나 되네요...
python 입니다. 1개 숫자에 해당하는 그림 그리기를 7자리 자료구조로 만들었습니다.
x = { 1:'0010010',2:'1011101',3:'1011011',4:'0111010',5:'1101011',
6:'1101111',7:'1010010',8:'1111111',9:'1111011',0:'1110111'}
# n:'one two three four five six seven'
def func(s):
one, two, three, four, five, six, seven = [], [], [], [], [], [], []
size = int(s[0])
numbers = s[2:]
for no in numbers:
xx = x[int(no)] # ex) if no==1, xx = '0010010'
one.append(xx[0])
two.append(xx[1])
three.append(xx[2])
four.append(xx[3])
five.append(xx[4])
six.append(xx[5])
seven.append(xx[6])
z1 = [' ', '-']; z2 = [' ', '|']
for i in range(len(numbers)): # one
print ' ' + z1[int(one[i])]*size + ' '*2,
print ''
for i in range(size): # two, three
for i in range(len(numbers)):
print z2[int(two[i])] + ' '*size + z2[int(three[i])] + ' ',
print ''
for i in range(len(numbers)): # four
print ' ' + z1[int(four[i])]*size + ' '*2,
print ''
for i in range(size): # five, six
for i in range(len(numbers)):
print z2[int(five[i])] + ' '*size + z2[int(six[i])] + ' ',
print ''
for i in range(len(numbers)): # seven
print ' ' + z1[int(seven[i])]*size + ' '*2,
print ''; print ''
func("2 12345")
func("3 67890")
coding by python beginner
inps = []
while True:
t0 = input().split()
if t0 == ['0', '0']: break
inps.append(t0)
def drawHorizontal( nums, vidx, w ):
rs = ''; disp = [[0,1,2],[],[],[0,2],[],[],[1,2],[],[],[1]]
for num in nums:
if vidx not in disp[int(num)-1]: rs += ' ' + '-' * w + ' '
else: rs += ' ' * ( w + 2 ) + ' '
return rs
def drawVertical( nums, vidx, w ):
rs = ''; disp = [[0,2],[0,3],[0,2],[2],[1,2],[1],[0,2],[],[2],[]]
for num in nums:
rs += ( '|' if vidx not in disp[int(num)-1] else ' ' ) + (' ' * w) + ('|' if vidx+1 not in disp[int(num)-1] else ' ') + ' '
return rs
for l in inps:
for i in range(3):
print( drawHorizontal( l[1], i, int(l[0]) ) )
if i<2:
for j in range( int(l[0]) ): print( drawVertical( l[1], i*2, int(l[0]) ) )
scala로 구현했습니다.
case class Line(p: String, m: String, s: String) {
def render(n: Int): String = p + m * n + s
}
case class Number(lines: Line*) {
def render(n: Int): List[String] = {
lines.zipWithIndex.flatMap { case (line, index) =>
if(index % 2 == 0) {
List(line.render(n))
} else {
List.fill(n)(line.render(n))
}
} toList
}
}
val dh0 = Line(" ", " ", " ")
val dh1 = Line(" ", "-", " ")
val dvl = Line("|", " ", " ")
val dvr = Line(" ", " ", "|")
val dvb = Line("|", " ", "|")
val dN: Map[Int, Number] = Map(
0 -> Number(dh1, dvb, dh0, dvb, dh1),
1 -> Number(dh0, dvr, dh0, dvr, dh0),
2 -> Number(dh1, dvr, dh1, dvl, dh1),
3 -> Number(dh1, dvr, dh1, dvr, dh1),
4 -> Number(dh0, dvb, dh1, dvr, dh0),
5 -> Number(dh1, dvl, dh1, dvr, dh1),
6 -> Number(dh1, dvl, dh1, dvb, dh1),
7 -> Number(dh1, dvr, dh0, dvr, dh0),
8 -> Number(dh1, dvb, dh1, dvb, dh1),
9 -> Number(dh1, dvb, dh1, dvr, dh1)
)
def display(s: Int, n: Int*): String = {
@scala.annotation.tailrec
def fn(numbers: List[List[String]], acc: List[String]): String = {
if(numbers.exists(_.isEmpty)) acc.reverse.mkString("\n")
else {
val heads = numbers.map(_.head).mkString(" ")
val tails = numbers.map(_.tail)
fn(tails, heads :: acc)
}
}
val numbers: List[List[String]] = n.map(dN.apply).map(_.render(s)).toList
fn(numbers, Nil)
}
println(display(2, 1,2,3,4,5))
println(display(3, 6,7,8,9,0))
Using python
전혀 beginner가 아닌 것 같으신 vegan님의 매핑을 보고 좀 따라 했네요 저걸 저렇게 해도 되고 앞에 분들처럼 7부분으로 나눠서 매핑을 해도 되고 골프 치시는 분들처럼 byte 계산하거나 bit연산 해도 되는 것 같네요 방법은 무궁무진...다만 이해가..
H = [[1],[0,1,2],[],[],[0,2],[],[],[1,2],[],[]]
V = [[],[0,2],[0,3],[0,2],[2],[1,2],[1],[0,2],[],[2]]
def printH(number, idx, n):
arr = ""
for num in number:
if idx in H[int(num)]:
arr += " "*(n+2) + " "
else:
arr += " "+"-"*n+" "
return arr
def printV(number, idx, n):
arr = ""
for num in number:
if idx in V[int(num)]:
arr += ' '+" "*n
else:
arr += '|'+" "*n
if idx+1 in V[int(num)]:
arr += ' '
else:
arr += '| '
return arr
def lcdN():
while True:
n,numbers = raw_input().split()
n = int(n)
for i in xrange(3):
print printH(numbers, i, n)
if i<2:
for j in xrange(n):
print printV(numbers, i*2, n)
lcdN()
c입니다.
#include<stdio.h>
#include<stdlib.h>
int *Digits(int num)
{
int *digits = malloc(sizeof(int) * 9);
int i;
for(i=1;i<9;i++)
{
if (num<10)
{
digits[i] = num;
digits[0] = i;
break;
}
digits[i] = num % 10;
num = num / 10;
}
return digits;
}
void LCD(int size, int digit)
{
int row, col, digit_col;
int *digits = Digits(digit);
for (col=digits[0];col>0;col--)
{
if (digits[col] == 1 || digits[col] == 4)
{
for (digit_col=0;digit_col<size+2;digit_col++)
{
printf(" ");
}
}
else
{
printf(" ");
for (digit_col=0;digit_col<size;digit_col++)
{
printf("-");
}
printf(" ");
}
printf(" ");
}
printf("\n");
for(row=0;row<size;row++)
{
for(col=digits[0];col>0;col--)
{
if (digits[col]==1 || digits[col]==2 || digits[col]==3 || digits[col]==7)
{
for(digit_col=0;digit_col<size+1;digit_col++)
{
printf(" ");
}
printf("|");
}
else if (digits[col]==5 || digits[col]==6)
{
printf("|");
for(digit_col=0;digit_col<size+1;digit_col++)
{
printf(" ");
}
}
else
{
printf("|");
for(digit_col=0;digit_col<size;digit_col++)
{
printf(" ");
}
printf("|");
}
printf(" ");
}
printf("\n");
}
for (col=digits[0];col>0;col--)
{
if (digits[col] == 1 || digits[col] == 7 || digits[col] == 0)
{
for (digit_col=0;digit_col<size+2;digit_col++)
{
printf(" ");
}
}
else
{
printf(" ");
for (digit_col=0;digit_col<size;digit_col++)
{
printf("-");
}
printf(" ");
}
printf(" ");
}
printf("\n");
for(row=0;row<size;row++)
{
for(col=digits[0];col>0;col--)
{
if (digits[col]==1 || digits[col]==4 || digits[col]==3 || digits[col]==7 || digits[col]==5 || digits[col]==9)
{
for(digit_col=0;digit_col<size+1;digit_col++)
{
printf(" ");
}
printf("|");
}
else if (digits[col]==2)
{
printf("|");
for(digit_col=0;digit_col<size+1;digit_col++)
{
printf(" ");
}
}
else
{
printf("|");
for(digit_col=0;digit_col<size;digit_col++)
{
printf(" ");
}
printf("|");
}
printf(" ");
}
printf("\n");
}
for (col=digits[0];col>0;col--)
{
if (digits[col] == 1 || digits[col] == 4 || digits[col] == 7)
{
for (digit_col=0;digit_col<size+2;digit_col++)
{
printf(" ");
}
}
else
{
printf(" ");
for (digit_col=0;digit_col<size;digit_col++)
{
printf("-");
}
printf(" ");
}
printf(" ");
}
printf("\n");
printf("\n");
}
int main()
{
int size, digit;
scanf("%d %d", &size, &digit);
while (size != 0 || digit != 0)
{
LCD(size, digit);
scanf("%d %d", &size, &digit);
}
return 0;
}
기존 알고리즘인지는 잘 모르겠으나 (다 보기가 힘들어서;;;) 제 나름 대로 짜본 Python code입니다.
처음엔 이걸 어떻게해 했는데 하다보니 잼있네요.(코딩의 묘미가 이닐까하는 ㅎㅎ)
제가 생각한 개념(?)은 아래와 같습니다.
공백(' ')은 숫자 0 !!
'-'나 '|'를 그려야 할땐 숫자 1
한 Line당 List를 만들어 List를 한줄 한줄 읽으면서 그려가자
1을 기본 크기로 잡고 그때 0부터 9까지의 숫자를 0과 1의 list로 만들어 놓고 입력되는 크기에 맞게 list를 키운다.
설명이 난해한데... 아래 소스보시고 이해해보시면 될것 같습니다.
# -*- coding: utf-8 -*-
import sys
def printNumber (displayList, inputCounter): # 1이 있는 곳에서 -나 |를 그릴 함수
lineCounter = 1
for i in displayList:
for j in i:
if lineCounter%(inputCounter +1)==1:
if j == 0 : sys.stdout.write(" ") #\n가 자동적으로 붙은 print대신 사용
elif j == 1 : sys.stdout.write("-")
else:
if j == 0 : sys.stdout.write(" ")
elif j == 1 : sys.stdout.write("|")
lineCounter +=1
sys.stdout.write("\n")
def increaseMidlList (refList,counter):
tempCounter = 0
for i in refList:
tempCounter = counter
tempCounter = tempCounter - 1
while tempCounter :
i.insert(1,i[1])
tempCounter -=1
#---------------------------------------------------
while 1:
scaleNumber = 0
userInput=[]
numberInt = []
secondLineCounter = 0
fourthLineCounter = 0
inputCounter = 0
userInput = list(raw_input('크기와 표시할 숫자를 입력 하세요 :'))
for i in userInput:
if i == ' ':
userInput.pop(inputCounter)
inputCounter +=1
scaleNumber = int(userInput[0])
userInput.pop(0)
for i in userInput: numberInt.append(int(i))
if scaleNumber == 0 and numberInt[0] == 0: break
else:
#0부터 9까지 숫자를 크기 1 일때 display된는 그림을 Refrence로 삼고 그것을 가로로 잘랐을 때 -와 |가 들어가는 부분에 대해 1로 적는다.
firstLineRefList = [[0,1,0],[0,0,0],[0,1,0],[0,1,0],[0,0,0],[0,1,0],[0,0,0],[0,1,0],[0,1,0],[0,1,0]] #0,1,2,3,4,5,6,7,8,9
secondLineRefList = [[1,0,1],[0,0,1],[0,0,1],[0,0,1],[1,0,1],[1,0,0],[1,0,0],[1,0,1],[1,0,1],[1,0,1]]
thirdtLineRefList = [[0,0,0],[0,0,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,0,0],[0,1,0],[0,1,0]]
fourthLineRefList = [[1,0,1],[0,0,1],[1,0,0],[0,0,1],[0,0,1],[0,0,1],[1,0,1],[0,0,1],[1,0,1],[0,0,1]]
fifthLineRefList = [[0,1,0],[0,0,0],[0,1,0],[0,1,0],[0,0,0],[0,1,0],[0,1,0],[0,0,0],[0,1,0],[0,0,0]]
#input으로들어올 숫자 대로 넣어줄 List
#최종적으로 그려질 숫자들의 각 가로별 bit map list
totalDisplayNumberList =[]
firstLineDispNumberList =[]
secondLineDispNumberList =[]
thirthLineDispNumberList =[]
fourthLineDispNumberList =[]
fifthLineDispNumberList =[]
#크기를 결정하는 숫자만큼 가운데 숫자를 복사해서 숫자의 크기를 키운다.
increaseMidlList(firstLineRefList, scaleNumber)
increaseMidlList(secondLineRefList, scaleNumber)
increaseMidlList(thirdtLineRefList, scaleNumber)
increaseMidlList(fourthLineRefList, scaleNumber)
increaseMidlList(fifthLineRefList, scaleNumber)
#Ref로 만든 List를 Display할 List에 넣어준다.
#이때 각 숫자사이마다 반칸을 넣기 위해 0을 한번씩 넣어준다.
for i in numberInt:
firstLineDispNumberList += firstLineRefList[i]
firstLineDispNumberList.append(0)
secondLineDispNumberList += secondLineRefList[i]
secondLineDispNumberList.append(0)
thirthLineDispNumberList += thirdtLineRefList[i]
thirthLineDispNumberList.append(0)
fourthLineDispNumberList += fourthLineRefList[i]
fourthLineDispNumberList.append(0)
fifthLineDispNumberList += fifthLineRefList[i]
fifthLineDispNumberList.append(0)
#최종적으로 만들어진 list들을 다 묶는다
#이때 2,4번째는 크기만큼 연속으로 append해준다.
totalDisplayNumberList.append(firstLineDispNumberList)
while secondLineCounter < scaleNumber :
totalDisplayNumberList.append(secondLineDispNumberList)
secondLineCounter +=1
totalDisplayNumberList.append(thirthLineDispNumberList)
while fourthLineCounter < scaleNumber :
totalDisplayNumberList.append(fourthLineDispNumberList)
fourthLineCounter +=1
totalDisplayNumberList.append(fifthLineDispNumberList)
printNumber(totalDisplayNumberList, scaleNumber)
항상 생각보다 어렵네요!! 내공이 길러지길,,!
def digit(nums,s):
if nums>=10:
num= str(nums)[-1]
nums2=int(str(nums)[:-1])
result1=[" "," "*s," "]
result2=[" "," "*s," "]
result3=[" "," "*s," "]
result4=[" "," "*s," "]
result5=[" "," "*s," "]
if num not in "14": result1[1]="-"*s
if num not in "123": result2[0]="|"
if num not in "56": result2[2]="|"
if num not in "170": result3[1]="-"*s
if num not in "134579": result4[0]="|"
if num not in "2": result4[2]="|"
if num not in "1479": result5[1]="-"*s
result=digit(nums2,s)
new_result=[result[0]+result1,result[1]+result2,result[2]+result3,result[3]+result4,result[4]+result5]
return new_result
else:
num= str(nums)
result1=[" "," "*s," "]
result2=[" "," "*s," "]
result3=[" "," "*s," "]
result4=[" "," "*s," "]
result5=[" "," "*s," "]
if num not in "14": result1[1]="-"*s
if num not in "123": result2[0]="|"
if num not in "56": result2[2]="|"
if num not in "170": result3[1]="-"*s
if num not in "134579": result4[0]="|"
if num not in "2": result4[2]="|"
if num not in "1479": result5[1]="-"*s
return [result1,result2,result3,result4,result5]
def reform(num,s):
result=digit(num,s)
result[1:2]=[result[1]]*s
result[-2:-1]=[result[-2]]*s
return result
for x in reform(123,1):
print "".join(x)
print
public class LCDDisplay {
public static void main(String[] args) {
int n = 1;
String digits = "";
LCDDisplay lcdDisplay = new LCDDisplay();
Scanner sc = new Scanner(System.in);
while(n != 0) {
n = sc.nextInt();
digits = sc.nextLine();
lcdDisplay.display(n, digits.trim());
}
sc.close();
}
public void display(int n, String digits) {
String[] map = {
"1110111", "0010010", "1011101",
"1011011", "0111010", "1101011",
"1101111", "1010010", "1111111",
"1111011"
};
char[][] lcd = new char[2 * n + 3][(n + 3) * digits.length()];
for(int i = 0; i < lcd.length; i++) {
for(int j = 0; j < lcd[i].length; j++) {
lcd[i][j] = ' ';
}
}
int offset = 0;
for(int k = 0; k < digits.length(); k++) {
int temp = digits.charAt(k) - '0';
for(int i = 0; i < map[temp].length(); i++) {
if(map[temp].charAt(i) == '1') {
if(i % 3 == 0) {
int x = offset + 1, y = 0;
switch(i) {
case 0: y = 0; break;
case 3: y = n + 1; break;
case 6: y = 2 * n + 2; break;
}
for(int j = 0; j < n; j++) {
lcd[y][x + j] = '-';
}
} else {
int x = offset, y = 0;
switch(i) {
case 1:
y = 1;
break;
case 2:
x += n + 1;
y = 1;
break;
case 4:
y = n + 2;
break;
case 5:
x += n + 1;
y = n + 2;
break;
}
for(int j = 0; j < n; j++) {
lcd[y + j][x] = '|';
}
}
}
}
offset += n + 3;
}
for(int i = 0; i < lcd.length; i++) {
System.out.println(lcd[i]);
}
System.out.println();
}
}
char LCDarr[5][3] = { { ' ','-',' ' },{ ' ',' ',' ' }, { '|',' ',' ' },{ ' ',' ','|' },{ '|',' ','|' } };
int getLen(int input)
{
int result = 0;
while (input > 0)
{
result++;
input /= 10;
}
return result;
}
int getCip(int num, int cip)
{
int *arr;
int len = getLen(num);
arr = (int *)malloc(sizeof(int) * getLen(num));
for (int i = 0; i < len; i++)
{
arr[i] = num % 10;
num /= 10;
}
return arr[len - cip];
}
void printDot(int scale, int dispaly)
{
printf("%c", LCDarr[dispaly][0]);
for (int i = 0; i < scale; i++)
printf("%c", LCDarr[dispaly][1]);
printf("%c ", LCDarr[dispaly][2]);
}
void setDisplay(int num, int *display)
{
switch (num)
{
case 0:
display[0] = 0;
display[1] = 4;
display[2] = 1;
display[3] = 4;
display[4] = 0;
break;
case 1:
display[0] = 1;
display[1] = 3;
display[2] = 1;
display[3] = 3;
display[4] = 1;
break;
case 2:
display[0] = 0;
display[1] = 3;
display[2] = 0;
display[3] = 2;
display[4] = 0;
break;
case 3:
display[0] = 0;
display[1] = 3;
display[2] = 0;
display[3] = 3;
display[4] = 0;
break;
case 4:
display[0] = 1;
display[1] = 4;
display[2] = 0;
display[3] = 3;
display[4] = 1;
break;
case 5:
display[0] = 0;
display[1] = 2;
display[2] = 0;
display[3] = 3;
display[4] = 0;
break;
case 6:
display[0] = 0;
display[1] = 2;
display[2] = 0;
display[3] = 4;
display[4] = 0;
break;
case 7:
display[0] = 0;
display[1] = 4;
display[2] = 1;
display[3] = 3;
display[4] = 1;
break;
case 8:
display[0] = 0;
display[1] = 4;
display[2] = 0;
display[3] = 4;
display[4] = 0;
break;
case 9:
display[0] = 0;
display[1] = 4;
display[2] = 0;
display[3] = 3;
display[4] = 0;
break;
}
}
void printNum(int scale, int num)
{
int display[5];
for (int i = 0; i < getLen(num); i++)
{
setDisplay(getCip(num, i + 1), display);
printDot(scale, display[0]);
}
printf("\n");
for (int j = 0; j < scale; j++)
{
for (int i = 0; i < getLen(num); i++)
{
setDisplay(getCip(num, i + 1), display);
printDot(scale, display[1]);
}
printf("\n");
}
for (int i = 0; i < getLen(num); i++)
{
setDisplay(getCip(num, i + 1), display);
printDot(scale, display[2]);
}
printf("\n");
for (int j = 0; j < scale; j++)
{
for (int i = 0; i < getLen(num); i++)
{
setDisplay(getCip(num, i + 1), display);
printDot(scale, display[3]);
}
printf("\n");
}
for (int i = 0; i < getLen(num); i++)
{
setDisplay(getCip(num, i + 1), display);
printDot(scale, display[4]);
}
printf("\n");
}
void exce3()
{
int scale, num;
int *numArr,len;
printf("출력 규모 입력 : ");
scanf_s("%d", &scale);
printf("숫자 입력 : ");
scanf_s("%d", &num);
printNum(scale, num);
}
어떻게든 구현 해 보려고 짜다보니 영 지저분 한거 같습니다. ㅠㅠ 각 숫자에 대해서 구성 문자를 미리 설정 해 두고 숫자를 받아서 1자리씩 짤라다가 한줄씩 한줄씩 차례로 프린트 하는 방식을 상요하였습니다.
조언이나 개선 환영합니다 ㅠㅠ
#include <iostream>
using namespace std;
int getCipherOfNumber(int number);
char** drawLCDNumber(int spacePerNumber, int s, char** arr);
int numberArray[8] = {-1, };
int chipherOfNumber = 0;
int main() {
int s = -1, n = -1;
int row = 0, column = 0;
int spacePerNumber = 0;
int inputArray[50][2] = {-1, };
int i=0;
while(1) {
cin >> s >> n;
if(s==0 && n==0) break;
else {
inputArray[i][0] = s;
inputArray[i][1] = n;
i++;
}
}
for(int i=0; i<50; i++) {
if(inputArray[i][0]==0 || inputArray[i][1]==0) break;
else {
s = inputArray[i][0];
n = inputArray[i][1];
chipherOfNumber = getCipherOfNumber(n);
row = (2*s)+3;
spacePerNumber = s+2;
column = (spacePerNumber*chipherOfNumber) + (chipherOfNumber-1);
char** arr = new char* [row];
for(int i=0; i<row; i++) {
arr[i] = new char[column];
}
arr = drawLCDNumber(spacePerNumber, s, arr);
for(int i=0; i<row; i++) {
for(int j=0; j<column; j++) {
cout << arr[i][j];
}
cout << endl;
}
}
}
return 0;
}
int getCipherOfNumber(int number) {
int num = number;
int divideNumber = 10;
int i = 0;
int cipherOfNumber = 0;
if(num<=9) {
numberArray[i] = num;
}
while(num>9) {
numberArray[i++] = num%divideNumber;
num = num/divideNumber;
if(num>=0 && num <=9){
numberArray[i] = num;
break;
}
}
cipherOfNumber = i+1;
return cipherOfNumber;
}
char** drawLCDNumber(int spacePerNumber, int s, char** arr) {
char** tempArr = arr;
int row = (2*s)+3;
int column = (spacePerNumber*chipherOfNumber) + (chipherOfNumber-1);
for(int i=0; i<row; i++) {
for(int j=0; j<column; j++) {
tempArr[i][j] = ' ';
}
}
int start_m = 0, start_n = 0;
int last_m = (2*s)+3-1;
int last_n = spacePerNumber-1;
int gap = spacePerNumber+1;
for(int i=chipherOfNumber-1; i>=0; i--) {
if(numberArray[i]==1) {
int tempCnt = 0;
for(int m=1; m<last_m; m++) {
tempArr[m][last_n] = '|';
tempCnt++;
if(tempCnt == s) {
tempCnt = 0;
continue;
}
}
}
else {
if(numberArray[i]!=4) {
for(int n=start_n+1; n<last_n; n++) {
tempArr[start_m][n] = '-';
}
}
start_m++;
for(int m=start_m; m<start_m+s; m++) {
if(numberArray[i]!=2 && numberArray[i]!=3 && numberArray[i]!=7) {
tempArr[m][start_n] = '|';
}
if(numberArray[i]!=5 && numberArray[i]!=6) {
tempArr[m][last_n] = '|';
}
}
start_m = start_m+s;
if(numberArray[i]!=7 && numberArray[i]!=0) {
for(int n=start_n+1; n<last_n; n++) {
tempArr[start_m][n] = '-';
}
}
start_m++;
for(int m=start_m; m<start_m+s; m++) {
if(numberArray[i]==2 || numberArray[i]==6 || numberArray[i]==8 || numberArray[i]==0) {
tempArr[m][start_n] = '|';
}
if(numberArray[i]!=2) {
tempArr[m][last_n] = '|';
}
}
start_m = start_m+s;
if(numberArray[i]!=4 && numberArray[i]!=7) {
for(int n=start_n+1; n<last_n; n++) {
tempArr[start_m][n] = '-';
}
}
}
start_m = 0;
start_n += gap;
last_n += gap;
}
return tempArr;
}
다음과 같이 작성하였습니다. 좀 지저분하긴 하네요..;;
digits = ("-|| ||-", " | | ", "- |-| _", "- |- |-", " ||- | ", "-| _ |_", "-| _||_", "- | | ", "-||_||_", "-||_ |_")
siz, num = input("siz, val: ").split(' ')
siz = int(siz)
for i in range(0, 7):
for val in num:
if (i % 3 == 0):
print (' ' + digits[int(val)][i] * siz + ' ', end = " ")
elif (i % 3 == 1):
print (digits[int(val)][i] + ' ' * siz + digits[int(val)][i + 1], end=" ")
elif (i % 3 == 2):
print (digits[int(val)][i - 1] + ' ' * siz + digits[int(val)][i], end=" ")
print()
파이썬 3.5
file = 'temp.txt'
pBit = [0b1110111, 0b0100100, 0b1011101, 0b1101101, 0b0101110, 0b1101011, 0b1111010, 0b0100111, 0b1111111, 0b1101111]
b = ' ' # 빈칸
listBit = []
def makefile():
with open(file, 'w') as f:
f.write('2 12345\n3 67890\n0 0')
def pX(size, turnX):
for i in range(len(listBit)):
if listBit[i] >> turnX & 1 == 1:
print(b * 2 + '-' * size + b, end='')
else:
print(b * 2 + b * size + b, end='')
print()
def pY(size, turnY):
for j in range(size):
for i in range(len(listBit)):
if listBit[i] >> turnY & 1 == 1:
print(b + '|' + b * size, end='')
else:
print(b + b + b * size, end='')
if listBit[i] >> turnY + 1 & 1 == 1:
print('|', end='')
else:
print(b, end='')
print()
def printLed(ns):
size = int(ns[0])
del (listBit[:])
for i in range(len(ns[1])):
listBit.append(pBit[int(ns[1][i])])
pX(size, 0)
pY(size, 1)
pX(size, 3)
pY(size, 4)
pX(size, 6)
print()
makefile()
printJob = open(file).read().split('\n')
for va in printJob:
ns = va.split(' ')
if not len(ns) == 2 or not str.isdecimal(ns[0]) or not str.isdecimal(ns[1]):
print(' Input file error....')
exit(1)
printLed(ns)
#include <iostream>
#include <bitset>
#include <assert.h>
#include <list>
using namespace std;
class SevenSegment
{
public:
/*
- 0 -
| |
3 4
| |
- 1 -
| |
5 6
| |
- 2 -
*/
SevenSegment(std::bitset<7> dotData, int size = 1)
: m_dotData(dotData)
, m_size(size)
, m_lineCount(size * 2 + 3)
{
assert(size > 0);
}
virtual ~SevenSegment() = default;
protected:
std::bitset<7> m_dotData;
int m_size;
int m_lineCount;
public:
/*
* size가 3일때의 lineNum
--- : 0
| | : 1
| | : 2
| | : 3
--- : 4
| | : 5
| | : 6
| | : 7
--- : 8
*/
int drawLine(int lineNum) const
{
if (lineNum % (m_size + 1) == 0)
{
// 가로
int dotIdx = lineNum / (m_size + 1);
char ch = ' ';
if (m_dotData[dotIdx])
ch = '-';
std::cout << ' ';
for (int i = 0; i < m_size; ++i)
std::cout << ch;
std::cout << ' ';
}
else
{
// 세로
int dotIdx = 3 + lineNum / (m_lineCount >> 1) * 2;
if (m_dotData[dotIdx])
cout << '|';
else
cout << ' ';
for (int i = 0; i < m_size; ++i)
cout << ' ';
if (m_dotData[dotIdx + 1])
cout << '|';
else
cout << ' ';
}
std::cout << ' ';
return 0;
}
int getLineCount() const
{
return m_lineCount;
}
void setSize(int size)
{
m_size = size;
m_lineCount = size * 2 + 3;
}
};
class DigitDisplay
{
protected:
static SevenSegment s_digits[10];
public:
DigitDisplay()
: m_size(1)
{
}
virtual ~DigitDisplay() = default;
protected:
int m_size;
public:
void setSize(int size)
{
m_size = size;
for (auto& num : s_digits)
{
num.setSize(size);
}
}
int drawNumber(int number)
{
// 수의 자릿수를 분리합니다.
std::list<int> digitList;
int ten = 10;
while (number > 0)
{
int sliceNum = number % ten;
int num = sliceNum / (ten / 10);
digitList.push_front(num);
number -= sliceNum;
ten *= 10;
}
// 각 자릿수를 7세그먼트 형태로 출력합니다.
int lineCount = s_digits[0].getLineCount();
for (int i = 0; i < lineCount; ++i)
{
for (auto& num : digitList)
{
s_digits[num].drawLine(i);
}
cout << endl;
}
return 0;
}
};
SevenSegment DigitDisplay::s_digits[10] = {
{ std::bitset<7>("1111101") },
{ std::bitset<7>("1010000") },
{ std::bitset<7>("0110111") },
{ std::bitset<7>("1010111") },
{ std::bitset<7>("1011010") },
{ std::bitset<7>("1001111") },
{ std::bitset<7>("1101111") },
{ std::bitset<7>("1011001") },
{ std::bitset<7>("1111111") },
{ std::bitset<7>("1011111") }
};
int main()
{
DigitDisplay lcd;
while (true)
{
// 출력할 수와 그 크기를 입력받습니다.
int number = 0, size = 0;
cin >> size >> number;
if (size == 0 && number == 0) break;
// 수를 FND 형태로 출력합니다.
lcd.setSize(size);
lcd.drawNumber(number);
}
return 0;
}
제 코드가 가장 긴 것 같네요 ㅎㅎ,,,
space=(' ',' ',' ')
head=(' ','-',' ')
lPolar=('|',' ',' ')
rPolar=(' ',' ','|')
lrPolar=('|',' ','|')
n1=[space,lPolar,space,lPolar,space]
n2=[head,rPolar,head,lPolar,head]
n3=[head,rPolar,head,rPolar,head]
n4=[space,lrPolar,head,rPolar,space]
n5=[head,lPolar,head,rPolar,head]
n6=[head,lPolar,head,lrPolar,head]
n7=[head,rPolar,space,rPolar,space]
n8=[head,lrPolar,head,lrPolar,head]
n9=[head,lrPolar,head,rPolar,space]
n0=[head,lrPolar,space,lrPolar,head]
numbers=[n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n0]
def printNumbers(mm,scale=1):
res=[]
for c in str(mm):
res.append(numbers[int(c)])
for i in range(len(n1)):
if i==1 or i==3:
rp=scale
else:
rp=1
for _ in range(rp):
for chIdx,chr in enumerate(res):
for strkIdx,c in enumerate(chr[i]):
if(strkIdx==1):
print c*scale,
else:
print c,
print #linefeed
with open("input.txt",'r') as f:
lines=f.readlines()
for inputLine in lines:
inScale,inNum=map(int,inputLine.split(' '))
if(inScale==0 and inNum==0):
break
else:
printNumbers(inNum,inScale)
#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''
d는 이진수로
디스플레이의 모양을 기술한다.
9876543210의 순서로 되어 있다.
예를 들어
1
11
1
01
1
이것은 9의 모양을 나타냄.
'''
d = [ 0b1110101101,
0b11110110101101010111,
0b1101111100,
0b01110111010101100111,
0b1101101101 ]
size, digit = raw_input().split()
h=' -'
v=' |'
size = eval(size)
for i in range(5):
if i%2 == 0 :
print ''.join(' '+h[d[i]>>int(s)&1]*size+' ' for s in digit)
else :
line =''.join(v[ d[i]>>(int(s)*2+1)&1 ]+\
' '*size + v[ d[i]>>(int(s)*2)&1 ]+' ' for s in digit)
print (line+'\n')*size,
Python3로 작성하였습니다.
material = (' ', ' - ', '| ', '| |', ' |')
numToDigit = [[1, 3, 0, 3, 1], [0, 4, 0, 4, 0], [1, 4, 1, 2, 1], [1, 4, 1, 4, 1], [0, 4, 1, 4, 0], [1, 2, 1, 4, 1], [1, 2, 1, 3, 1], [1, 4, 0, 4, 0], [1, 3, 1, 3, 1], [1, 3, 1, 4, 0]]
def showDigit(size, num):
digitNum = [int(n) for n in str(num)]
for i in range(5):
results = []
for digit in digitNum:
n = numToDigit[digit][i]
results.append(material[n][0] + material[n][1] * size + material[n][2])
for j in range(size if i == 1 or i == 3 else 1):
print(' '.join(results))
showDigit(2, 12345)
showDigit(3, 67890)
showDigit(0, 0)
결과
-- -- --
| | | | |
| | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
Haskell로 작성하였습니다.
import Data.Char (digitToInt)
material = [" ", " - ", "| ", "| |", " |"]
numToDigit = [[1, 3, 0, 3, 1], [0, 4, 0, 4, 0], [1, 4, 1, 2, 1], [1, 4, 1, 4, 1], [0, 4, 1, 4, 0], [1, 2, 1, 4, 1], [1, 2, 1, 3, 1], [1, 4, 0, 4, 0], [1, 3, 1, 3, 1], [1, 3, 1, 4, 0]]
chain xs with n
| n == 0 = []
| otherwise = xs ++ with ++ (chain xs with (n-1))
showDigit size num = [chain (getLine i) "\n" (if i `mod` 2 == 0 then 1 else size) | i <- [0..4]]
where
digitNums = [digitToInt n | n <- show num]
getMaterial digitNum i = (numToDigit !! digitNum) !! i
getLine i = foldl (\acc x -> acc ++ (head x:"") ++ (chain (x !! 1:"") "" size) ++ (last x:"") ++ " ") "" [material !! (getMaterial curDigitNum i) | curDigitNum <- digitNums]
-- Run
main = do mapM_ (\xs -> mapM_ putStr xs) [showDigit 2 12345, showDigit 3 67890, showDigit 0 0]
결과
-- -- --
| | | | |
| | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
#include <stdio.h>
#include <string.h>
void print_ch(char * str,int len,int s);
void print_c1(int s);
void print_c2(int s);
void print_cm(char * str,int len,int s);
void print_cl(char * str,int len,int s);
void print_rh(char * str,int len,int s);
void print_rl(char * str,int len,int s);
void print_r1(int s);
void print_r2(int s);
void print_r3(int s);
int main(void)
{
char str[11];
int s;
scanf("%d %s",&s,str);
print_ch(str,strlen(str),s);
print_rh(str,strlen(str),s);
print_cm(str,strlen(str),s);
print_rl(str,strlen(str),s);
print_cl(str,strlen(str),s);
return 0;
}
void print_ch(char * str,int len,int s)
{
//heigh col
int i;
for(i=0;i<len;i++)
{
switch(str[i])
{
case '1':case '4':
print_c1(s);
break;
default:
print_c2(s);
}
printf(" ");
}
printf("\n");
}
void print_cm(char * str,int len,int s)
{
int i;
for(i=0;i<len;i++)
{
switch(str[i])
{
case '1':case '7': case '0':
print_c1(s);
break;
default:
print_c2(s);
}
printf(" ");
}
printf("\n");
}
void print_cl(char * str,int len,int s)
{
int i;
for(i=0;i<len;i++)
{
switch(str[i])
{
case '1':case '4': case '7':
print_c1(s);
break;
default:
print_c2(s);
}
printf(" ");
}
printf("\n");
}
void print_c1(int s)
{
int i;
for(i=0;i<s+2;i++)
printf(" ");
return;
}
void print_c2(int s)
{
int i;
printf(" ");
for(i=0;i<s;i++)
printf("-");
printf(" ");
return;
}
void print_rh(char *str,int len,int s)
{
int i;int j;
for(i=0;i<s;i++)
{
for(j=0;j<len;j++)
{
switch(str[j])
{
case '5':case'6':
print_r1(s);
break;
case '1':case '2': case '3':
print_r2(s);
break;
default:
print_r3(s);
}
printf(" ");
}
printf("\n");
}
}
void print_rl(char * str,int len,int s)
{
int i;int j;
for(i=0;i<s;i++)
{
for(j=0;j<len;j++)
{
switch(str[j])
{
case '2':
print_r1(s);
break;
case '0':case '8':case '6':
print_r3(s);
break;
default:
print_r2(s);
}
printf(" ");
}
printf("\n");
}
}
void print_r1(int s)
{
int i;
printf("|");
for(i=0;i<s+1;i++)
printf(" ");
}
void print_r2(int s)
{
int i;
for(i=0;i<s+1;i++)
printf(" ");
printf("|");
}
void print_r3(int s)
{
int i;
printf("|");
for(i=0;i<s;i++)
printf(" ");
printf("|");
}
결과
3 1234567890
--- --- --- --- --- --- --- ---
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
--- --- --- --- --- --- ---
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
--- --- --- --- --- --- ---
한글자를 표시하는 칸의 7군데의 액정이 on 되는 글자들을 준비해서 (별로 안좋아하는) 2차원배열상에서 켜진 액정의 글자를 바꾸는 식으로 최종출력될 문자열을 만들도록 대충 꾸겨넣어서 만들어서 엄청 허접하게 나왔네요 ㅠㅠ
def do(numbers, size=2):
key = ('02356789', '0456789', '01234789', '2345689', '0268', '013456789', '0235689')
tray = [[' '] * (2 * size + 1) * len(numbers) for _ in range(2 * size + 3)]
def mark_digit(mask, idx):
digitWidth = 2 * size + 1
startingY = 0
startingX = digitWidth * idx
# upper -
if mask[0]:
tray[0][startingX + 1:startingX + 1 + size] = ['-'] * size
# left-upper |
if mask[1]:
for i in range(size):
tray[i+1][startingX] = '|'
# right-upper |
if mask[2]:
for i in range(size):
tray[i+1][startingX + 1 + size] = '|'
# middle -
if mask[3]:
tray[startingY + size + 1][startingX + 1:startingX + 1 + size] = ['-'] * size
# left-lower |
if mask[4]:
for i in range(size):
tray[size + 2 + i][startingX] = '|'
# right-lower |
if mask[5]:
for i in range(size):
tray[size + 2 + i][startingX + size + 1] = '|'
# bottom -
if mask[6]:
tray[startingY + 2 * size + 2][startingX + 1:startingX + 1 + size] = ['-'] * size
for i, c in enumerate(numbers):
mark_digit([c in k for k in key], i)
print('\n'.join((''.join(line) for line in tray)))
_numbers = input()
_size = int(input())
do(_numbers, _size)
mask 정보를 이용하면 프린터처럼 한줄씩 출력하도록 처리하면 배열도 필요없을것 같습니다. 그래서 이렇게 수정했습니다.
def do2(numbers, size=2):
key = ('02356789', '0456789', '01234789', '2345689', '0268', '013456789', '0235689')
for h in range(size * 2 + 3):
if h is 0:
print(' '.join([(' ' + '-' * size + ' ') if c in key[0] else ' ' * (size + 2)\
for c in numbers]))
elif h < size + 1:
print(' '.join([('|' if c in key[1] else ' ') + (' ' * size) +\
('|' if c in key[2] else ' ') for c in numbers]))
elif h == size + 1:
print(' '.join([(' ' + '-' * size + ' ') if c in key[3] else ' ' * (size + 2)\
for c in numbers]))
elif h < 2 * (size + 1):
print(' '.join([('|' if c in key[4] else ' ') + (' ' * size) +\
('|' if c in key[5] else ' ') for c in numbers]))
else:
print(' '.join([(' ' + '-' * size + ' ') if c in key[6] else ' ' * (size + 2)\
for c in numbers]))
_numbers = '1234567890'
_size = int(input())
do2(_numbers, _size)
파이썬 3.4.2
pri = []
def stringit(s,r0,r1,c1,c2,c3):
str1 = [r0] + [c3]*s + [r0] + [c3]*s + [r0]
str2 = [r1] + [c3]*s + [r1] + [c2]*s + [r1]
str3 = [r1] + [c3]*s + [r1] + [c3]*s + [r1]
str4 = [r0] + [c1]*s + [r1] + [c3]*s + [r0]
str5 = [r1] + [c2]*s + [r1] + [c3]*s + [r1]
str6 = [r1] + [c2]*s + [r1] + [c1]*s + [r1]
str7 = [r1] + [c3]*s + [r0] + [c3]*s + [r0]
str8 = [r1] + [c1]*s + [r1] + [c1]*s + [r1]
str9 = [r1] + [c1]*s + [r1] + [c3]*s + [r1]
str0 = [r1] + [c1]*s + [r0] + [c1]*s + [r1]
return [str0,str1,str2,str3,str4,str5,str6,str7,str8,str9]
while True:
s,n = map(int,input().split())
if s == 0 and n == 0:
break
row1 = ' ' + '-'*s + ' '
row0 = ' '*(s+2)
col1 = '|' + ' '*s + '|'
col2 = '|' + ' '*(s+1)
col3 = ' '*(s+1) + '|'
digit = stringit(s,row0,row1,col1,col2,col3)
pri.append((n,digit,s))
for t in pri:
n = t[0]
dig = t[1]
for i in range(2*t[2]+3):
for key in str(n):
print(dig[int(key)][int(i)],end=' ')
print()
print()
간단히 할 수 있으면 댓글을 부탁드립니다.
hh=["-"," ","-","-"," ","-","-","-","-","-"]
mh=["|","|"," ","|"," ","|"," ","|","|","|","|"," ","|"," "," ","|","|","|","|","|"]
mm=[" "," ","-","-","-","-","-"," ","-","-"]
ml=["|","|"," ","|","|"," "," ","|"," ","|"," ","|","|","|"," ","|","|","|"," ","|"]
ll=["-"," ","-","-"," ","-","-"," ","-","-"]
while 1:
a=input("size number:").split()
if a[0]=="0" and a[1]=="0":
break
s=int(a[0])
number=a[1]
hori=[]
for i in range(len(number)):
hori[i*(s+3):i*(s+3)+s+2]=[" "+hh[int(number[i])]*s+" "]
print(' '.join(hori)+" ")
hori=[]
for j in range(s):
for i in range(len(number)):
hori[i * (s + 3): i * (s + 3) + s + 2] = [mh[int(number[i])*2]+" "*s+mh[int(number[i])*2+1]]
print(' '.join(hori) + " ")
hori=[]
for i in range(len(number)):
hori[i * (s + 3):i * (s + 3) + s + 2] = [" " + mm[int(number[i])] * s + " "]
print(' '.join(hori) + " ")
hori = []
for j in range(s):
for i in range(len(number)):
hori[i * (s + 3): i * (s + 3) + s + 2] = [ml[int(number[i]) * 2] + " " * s + ml[int(number[i]) * 2 + 1]]
print(' '.join(hori) + " ")
hori = []
for i in range(len(number)):
hori[i * (s + 3):i * (s + 3) + s + 2] = [" " + ll[int(number[i])] * s + " "]
print(' '.join(hori)," ")
hori = []
Python3
digit_chart = (" ", " - ", "| ", "| |", " |")
num_digit = ((1, 3, 0, 3, 1),
(0, 4, 0, 4, 0),
(1, 4, 1, 2, 1),
(1, 4, 1, 4, 1),
(0, 4, 1, 4, 0),
(1, 2, 1, 4, 1),
(1, 2, 1, 3, 1),
(1, 4, 0, 4, 0),
(1, 3, 1, 3, 1),
(1, 3, 1, 4, 0))
def show_Digit(size, num):
for i in range(5):
output = []
for digit in [int(n) for n in str(num)]:
n = num_digit[digit][i]
output.append(digit_chart[n][0] + digit_chart[n][1] * size + digit_chart[n][2])
for j in range(size if i == 1 or i == 3 else 1):
print(" ".join(output))
show_Digit(2, 12345)
show_Digit(3, 67890)
Ruby
수를 다섯개 문자로 표현한 뒤 dic사전으로 스페이스, 대쉬, 막대기 문자열로 전환/출력
ex) 7은 DCSRS로 표현. D(대쉬),C(양쪽막대기),S(공백),R(오른쪽막대기),S(공백)
DGTS = %w(DSDDSDDDDD CRRRCLLRCC SSDDDDDSDD CRLRRRCRCR DSDDSDDSDD)
dic = ->n { s,d,l=" -|".chars; [s*(n+2),s+d*n+s,l+s*(n+1),l+s*n+l,s*(n+1)+l] }
cd_ = ->s,num { num.chars.map {|n| DGTS.map {|d| d[n.to_i] } }.
transpose.map.with_index {|a,i| [a]*(i.odd?? s:1) } }
lcd = ->s,num { s=s.to_i; dh="SDLCR".chars.zip(dic[s]).to_h
cd_[s,num].flatten(1).map {|line| line.map(&dh)*'' } }
out_lcd = proc { puts $<.map(&:split).map(&lcd) }
Test
expect(cd_[1,"0"]).to eq [[["D"]],
[["C"]],
[["S"]],
[["C"]],
[["D"]]]
expect(cd_[2,"0"]).to eq [[["D"]],
[["C"], ["C"]],
[["S"]],
[["C"], ["C"]],
[["D"]]]
expect(cd_[2,"40"]).to eq [[["S", "D"]],
[["C", "C"], ["C", "C"]],
[["D", "S"]],
[["R", "C"], ["R", "C"]],
[["S", "D"]]]
expect(lcd["2","40"]).to eq [" -- ", # S D
"| || |", # C C
"| || |", # C C
" -- ", # D S
" || |", # R C
" || |", # R C
" -- "] # S D
Output
#=> out_lcd[]
2 12345
3 67890
-- -- --
| | || ||
| | || ||
-- -- -- --
|| | | |
|| | | |
-- -- --
--- --- --- --- ---
| || || || |
| || || || |
| || || || |
--- --- ---
| | || | || |
| | || | || |
| | || | || |
--- --- --- ---
PHP로 작성해보았습니다. 멋있게 짤 머리는 안되니 최대한 순차적으로 작성한것을 최대한 함수에 압축시켜봤습니다. bitwise도 귀찮아서 패스.. 걍 공백사이즈때문에 그냥 테이블 그리기로... 잼있네요 ㅋ
$array = array();
$array[0] = array(1,0,1,1,1,1,1);
$array[1] = array(0,0,0,0,1,0,1);
$array[2] = array(1,1,1,0,1,1,0);
$array[3] = array(1,1,1,0,1,0,1);
$array[4] = array(0,1,0,1,1,0,1);
$array[5] = array(1,1,1,1,0,0,1);
$array[6] = array(1,1,1,1,0,1,1);
$array[7] = array(1,0,0,0,1,0,1);
$array[8] = array(1,1,1,1,1,1,1);
$array[9] = array(1,1,0,1,1,0,1);
$rules = array();
$rules[1] = 0;
$rules[3] = 1;
$rules[5] = 2;
$rules[2] = array(3,4);
$rules[4] = array(5,6);
drawNumbers(2, 12345);
drawNumbers(3, 67890);
function drawNumbers($size, $num) {
echo "<table>";
for($i=1; $i<=5; $i++) {
echo "<tr>";
drawLine($i, $size, $num);
echo "</tr>";
}
echo "</table>";
}
function drawLine($line, $size, $num) {
global $array, $rules;
$tmp = str_split((string)$num);
foreach($tmp as $char) {
if(!is_array($rules[$line])) {
if($array[$char][$rules[$line]]) {
$str = str_repeat("<td>-</td>",$size);
} else {
$str = str_repeat("<td> </td>",$size);
}
echo sprintf("<td> </td>%s<td> </td>",$str);
}
if(is_array($rules[$line])) {
if($array[$char][$rules[$line][0]]) {
$str1 = sprintf("<td>%s</td>",str_repeat("|<br>",$size));
} else {
$str1 = "<td> </td>";
}
$pad = str_repeat("<td> </td>",$size);
if($array[$char][$rules[$line][1]]) {
$str2 = sprintf("<td>%s</td>",str_repeat("|<br>",$size));
} else {
$str2 = "<td> </td>";
}
echo $str1.$pad.$str2;
}
echo "<td> </td>";
}
}
// java 그냥 scanner 으로
static int size = 3;
static int height = size * 2 + 3;
static int width = size + 2;
// 위, 왼쪽위, 오른쪽위, 중간, 왼쪽아래, 오른쪽아래, 밑
static boolean[] zero = new boolean[] { true, true, true, false, true, true, true };
static boolean[] one = new boolean[] { false, false, true, false, false, true, false };
static boolean[] two = new boolean[] { true, false, true, true, true, false, true };
static boolean[] three = new boolean[] { true, false, true, true, false, true, true };
static boolean[] four = new boolean[] { false, true, true, true, false, true, false };
static boolean[] five = new boolean[] { true, true, false, true, false, true, true };
static boolean[] six = new boolean[] { true, true, false, true, true, true, true };
static boolean[] seven = new boolean[] { true, false, true, false, false, true, false };
static boolean[] eight = new boolean[] { true, true, true, true, true, true, true };
static boolean[] nine = new boolean[] { true, true, true, true, false, true, false };
static boolean[][] total = new boolean[][] { zero, one, two, three, four, five, six, seven, eight, nine };
private static void Test() {
Scanner sc = new Scanner(System.in);
System.out.println("input size and number");
String SizeNum = sc.nextLine();
String Temp[] = SizeNum.split(",");
size = Integer.parseInt(Temp[0]);
String num = Temp[1];
for (int i = 0; i < height; i++) {
for (int l = 0; l < num.length(); l++) {
String figure = getFigure(i, Character.getNumericValue(num.charAt(l)));
System.out.print(figure);
System.out.print(" ");
}
System.out.println("");
}
sc.close();
}
private static String getFigure(int i, int l) {
String figure = "";
if (i == 0 || i == height / 2 || i == height - 1) { // 가로 위, 중간, 밑
for (int k = 0; k < width; k++) {
if (k == 0 || k == width - 1) {
figure += " ";
} else {
boolean compare = true;
if(i == 0) {
compare = total[l][0];
} else if (i == height / 2) {
compare = total[l][3];
} else if (i == height - 1) {
compare = total[l][6];
}
if (compare) {
figure += "-";
} else {
figure += " ";
}
}
}
} else { // 나머진 세로
for (int k = 0; k < width; k++) {
if (k != 0 && k != width - 1) {
figure += " ";
} else {
boolean compare = true;
if (i > 0 && i < height / 2) {
if (k == 0) {
compare = total[l][1];
} else if (k == width - 1) {
compare = total[l][2];
}
} else if (i > height / 2 && i < height - 1) {
if (k == 0) {
compare = total[l][4];
} else if (k == width - 1) {
compare = total[l][5];
}
}
if (compare) {
figure += "|";
} else {
figure += " ";
}
}
}
}
return figure;
}
package main
import (
"fmt"
)
var chars = []int{
// up up left up right middle down left down right down
(1 << 0) | (1 << 1) | (1 << 2) | (0 << 3) | (1 << 4) | (1 << 5) | (1 << 6), // 0
(0 << 0) | (0 << 1) | (1 << 2) | (0 << 3) | (0 << 4) | (1 << 5) | (0 << 6), // 1
(1 << 0) | (0 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (0 << 5) | (1 << 6), // 2
(1 << 0) | (0 << 1) | (1 << 2) | (1 << 3) | (0 << 4) | (1 << 5) | (1 << 6), // 3
(0 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (0 << 4) | (1 << 5) | (0 << 6), // 4
(1 << 0) | (1 << 1) | (0 << 2) | (1 << 3) | (0 << 4) | (1 << 5) | (1 << 6), // 5
(1 << 0) | (1 << 1) | (0 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6), // 6
(1 << 0) | (0 << 1) | (1 << 2) | (0 << 3) | (0 << 4) | (1 << 5) | (0 << 6), // 7
(1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6), // 8
(1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (0 << 4) | (1 << 5) | (1 << 6), // 9
}
func PrintH(sz int, nums string, mask int) {
c := " "
for _, r := range nums {
num := r - '0'
if (chars[num] & mask) != 0 {
c = "-"
} else {
c = " "
}
fmt.Print(" ")
for i := 0; i < sz; i++ {
fmt.Print(c)
}
fmt.Print(" ")
fmt.Print(" ")
}
fmt.Println()
}
func PrintV(sz int, nums string, mask1, mask2 int) {
c := " "
for _, r := range nums {
num := r - '0'
if (chars[num] & mask1) != 0 {
c = "|"
} else {
c = " "
}
fmt.Print(c)
for i := 0; i < sz; i++ {
fmt.Print(" ")
}
if (chars[num] & mask2) != 0 {
c = "|"
} else {
c = " "
}
fmt.Print(c)
fmt.Print(" ")
}
fmt.Println()
}
func PrintString(sz int, nums string) {
PrintH(sz, nums, (1<<0))
for i := 0; i < sz; i++ {
PrintV(sz, nums, (1<<1), (1<<2))
}
PrintH(sz, nums, (1<<3))
for i := 0; i < sz; i++ {
PrintV(sz, nums, (1<<4), (1<<5))
}
PrintH(sz, nums, (1<<6))
}
func main() {
var sz int
var nums string
fmt.Print("Input size: ")
fmt.Scanf("%d", &sz)
fmt.Print("Input numbers: ")
fmt.Scanf("%s", &nums)
PrintString(sz, nums)
}
li = [119, 18, 93, 91, 58, 107, 111, 82, 127, 123]
def d(n, s):
targets = list(li[int(x)] for x in s)
return ''.join((''.join(' ' + ('-' if t&(2**int(x/2*3)) else ' ')*n + ' ' for t in targets) + '\n') if x%2 == 0 else ((''.join(('|' if t&(2**(3*((x-1)//2)+2)) else ' ') + ' '*n + ('|' if t&(2**(3*((x-1)//2)+1)) else ' ') for t in targets)+'\n')*n) for x in range(4, -1, -1))
print(d(2, '12345'))
print(d(3, '67890'))
파이썬 3.5.1
Delphi 2010
function BitOff(Data: integer; Bits: array of integer): integer;
var
i: integer;
function _BitOff(Data, Bit: integer): integer;
begin
if (Bit < 32) then
Result := Data and (not(1 shl Bit))
else
Result := Data;
end;
begin
Result := Data;
for i := 0 to high(Bits) do
if (Bits[i] < 32) then
Result := _BitOff(Result, Bits[i]);
end;
function BitOn(Data: integer; Bits: array of integer): integer;
var
i: integer;
function _BitOn(Data, Bit: integer): integer;
begin
if (Bit < 32) then
Result := Data or (1 shl Bit)
else
Result := Data;
end;
begin
Result := Data;
for i := 0 to high(Bits) do
if (Bits[i] < 32) then
Result := _BitOn(Result, Bits[i]);
end;
function BitSet(Data, Bit: integer): Boolean;
begin
Result := (Bit < 32) and ((Data and (1 shl Bit)) > 0);
end;
procedure TForm4.Button3Click(Sender: TObject);
var
L: array [0 .. 10] of integer;
procedure Write_LED(Size: integer; s: string);
var
i, j, k, N: integer;
s2, s3, s4: string;
begin
for j := 0 to 4 do
begin
s2 := '';
for i := 1 to Length(s) do
begin
N := Ord(s[i]) - Ord('0');
// 첫행
case j of
0, 2, 4: //
begin
if j = 0 then
k := 0
else if j = 2 then
k := 6
else
k := 3;
if BitSet(L[N], k) then
s3 := ' ' + StringofChar('-', Size) + ' '
else
s3 := ' ' + StringofChar(' ', Size)+ ' ';
s2 := s2 + s3 + ' ';
end;
1, 3:
begin
if j = 1 then
k := 5
else
k := 4;
s4 := StringofChar(' ', Size-1);
if BitSet(L[N], k) then
s3 := '|' + s4
else
s3 := ' ' + s4;
s2 := s2 + s3;
if j = 1 then
k := 1
else
k := 2;
if BitSet(L[N], k) then
s3 := ' |'
else
s3 := ' ';
s2 := s2 + s3 + ' ';
end;
end;
end;
case j of
0, 2, 4:
Memo1.Lines.Add(s2);
else
begin
for k := 1 to Size do
Memo1.Lines.Add(s2);
end;
end;
end;
end;
begin
FillChar(L, sizeof(L), #0);
L[0] := BitOn(0, [0, 1, 2, 3, 4, 5]);
L[1] := BitOn(0, [1, 2]);
L[2] := BitOn(0, [0, 1, 3, 4, 6]);
L[3] := BitOn(0, [0, 1, 2, 3, 6]);
L[4] := BitOn(0, [1, 2, 5, 6]);
L[5] := BitOn(0, [0, 2, 3, 5, 6]);
L[6] := BitOn(0, [0, 2, 3, 4, 5, 6]);
L[7] := BitOn(0, [0, 1, 2, 5]);
L[8] := BitOn(0, [0, 1, 2, 3, 4, 5, 6]);
L[9] := BitOn(0, [0, 1, 2, 5, 6]);
Memo1.Lines.BeginUpdate;
Memo1.Lines.Clear;
Write_LED(4, '12345');
Memo1.Lines.Add('');
Write_LED(2, '67890');
Memo1.Lines.EndUpdate;
end;
길가의 꽃님의 코딩(오랑캐꽃님의 알고리즘) 바탕으로 하드웨어 코딩에 편하도록 코딩하였습니다. 간결한 파이썬의 특징이 나오지 않아 조금 아쉽네요.
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 15 05:06:32 2016
@author: user
"""
RomPatTP = ( ' - ', ' ', '-- ', '-- ', ' ', ' --', ' --', '-- ', ' - ', ' - ' )
RomPatTC = ( '| |', ' | ', ' |', ' |', '| |', '| ', '| ', ' |', '| |', '| |' )
RomPatCN = ( '| |', ' | ', ' - ', '-- ', ' - ', ' - ', ' - ', ' |', ' - ', ' - ' )
RomPatCB = ( '| |', ' | ', '| ', ' |', ' |', ' |', '| |', ' |', '| |', ' |' )
RomPatBT = ( ' - ', ' ', ' _ ', '-- ', ' ', ' - ', ' - ', ' ', ' - ', ' - ' )
def printDigit(digit, s_width, s_height):
k = 0
width = int(s_width)
height = int(s_height)
#i_half_height = int(height/2.0)
result = []
while k < width:
if k == 0: result.append(digit[0])
elif k == width - 1: result.append(digit[2])
else: result.append(digit[1])
k += 1
temp = "".join(result)
#print("*", temp)
return temp
#print ("".join(result),)
def printLcdStr(value, s_scale):
scale = int(s_scale)
if scale <1:
print("Scale 0 is not permitted!")
return
Width = scale + 2
Height = scale * 2 + 3
i_half_height = int(Height/2.0)
for i in range(0, Height):
result = []
for j in range(0, len(value)):
if i == 0: temp = printDigit(RomPatTP[int(value[j])], Width, Height)
elif i == Height - 1: temp = printDigit(RomPatBT[int(value[j])], Width, Height)
elif i == i_half_height : temp = printDigit(RomPatCN[int(value[j])], Width, Height)
elif i < i_half_height : temp = printDigit(RomPatTC[int(value[j])], Width, Height)
else: temp = printDigit(RomPatCB[int(value[j])], Width, Height)
result.append(temp)
#print("**")
s_temp = "".join(result)
print(s_temp)
# main Routine
s_line = input('<scale> <number> :')
i_scale, i_value = s_line.split()
if i_scale == "0" and i_value == '0':
print("End of program")
exit()
printLcdStr(i_value, i_scale)
package codingdojang;
class digit{
char[] dig;
char[][][] dig_n=
{{{' ','-',' '},{'|',' ','|'},{' ',' ',' '},{'|',' ','|'},{' ','-',' '}},
{{' ',' ',' '},{' ',' ','|'},{' ',' ',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{' ',' ','|'},{' ','-',' '},{'|',' ',' '},{' ','-',' '}},
{{' ','-',' '},{' ',' ','|'},{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ',' ',' '},{'|',' ','|'},{' ','-',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{'|',' ',' '},{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ',' ',' '},{'|',' ',' '},{' ','-',' '},{'|',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ','|'},{' ',' ',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{'|',' ','|'},{' ','-',' '},{'|',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ','|'},{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
};
int line_h = 0;
int line_b = 0;
digit(int size,String num){
line_h =size*2 + 3;
line_b = size + 2;
dig = num.toCharArray();
for(int i = 0; i<line_h;i++){
for(int k = 0;k<dig.length;k++){
for(int j = 0; j <line_b;j++){
if(j==0){ //도트(가로)간격
if(i == 0) System.out.print(dig_n[dig[k]-'0'][0][0]);//첫줄
else if( i == (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][2][0]); //가운댓줄
else if( i == line_h-1) System.out.print(dig_n[dig[k]-'0'][4][0]); //마지막줄
else if( i < (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][1][0]);//윗줄
else if( i > (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][3][0]);//아랫줄
}
else if(j==line_b-1){
if(i == 0) System.out.print(dig_n[dig[k]-'0'][0][2]);
else if( i == (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][2][2]);
else if( i == line_h-1) System.out.print(dig_n[dig[k]-'0'][4][2]);
else if( i < (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][1][2]);
else if( i > (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][3][2]);
}
else {
if(i == 0) System.out.print(dig_n[dig[k]-'0'][0][1]);
else if( i == (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][2][1]);
else if( i == line_h-1) System.out.print(dig_n[dig[k]-'0'][4][1]);
else if( i < (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][1][1]);
else if( i > (line_h-1)/2) System.out.print(dig_n[dig[k]-'0'][3][1]);
}
} System.out.print(" "); //숫자사이 간격
}System.out.println(); //도트사이 간격
}
}
}
public class lv2_09 {
public static void main(String[] args) {
// TODO Auto-generated method stub
String num = "1234567890";
int size = 4;
digit d = new digit(size,num);
}
}
자바로 풀었는데 아직 초심자라 그런지 노가다로만 푼거같네요 덕분에 3차원배열이라는것도 알고갑니다.
python 3.5 직관적으로 짜보았습니다.
#-*- coding: utf-8 -*-
f = open("input.txt", 'r')
def print_number(s, n):
height = 2*s+3
i=0
while i < height:
textline = ""
if i == 0:
print_type = 1
elif i <= s:
print_type = 2
elif i == s+1:
print_type = 3
elif i < height-1:
print_type = 4
else:
print_type = 5
for x in list(n):
textline += convertNumToMark(s, int(x), print_type)
i+=1
print(textline)
def convertNumToMark(s, num, print_type):
if print_type == 1:
a = list({0,2,3,5,6,7,8,9})
if a.count(num) > 0:
return " %s " % ("-"*s)
else :
return " %s " % (" "*s)
elif print_type == 2:
a = list({5,6}) #앞에만 있는 경우
b = list({1,2,3,7}) #뒤에만 있는 경우
if a.count(num) > 0:
return "|%s " % (" "*s)
elif b.count(num) > 0:
return " %s|" % (" "*s)
else :
return "|%s|" % (" "*s)
elif print_type == 3:
a = list({0,1,7}) #없는 경우
if a.count(num) > 0:
return " %s " % (" "*s)
else :
return " %s " % ("-"*s)
elif print_type == 4:
a = list({2}) #앞에만 있는 경우
b = list({1,3,4,5,7,9}) #뒤에만 있는 경우
if a.count(num) > 0:
return "|%s " % (" "*s)
elif b.count(num) > 0:
return " %s|" % (" "*s)
else :
return "|%s|" % (" "*s)
else:
a = list({1,4,7}) #없는 경우
if a.count(num) > 0:
return " %s " % (" "*s)
else :
return " %s " % ("-"*s)
while 1:
a = f.readline()
arr = a.split(' ')
s = int(arr[0])
n = arr[1].replace('\n','')
width = (s+2) * len(n) + (len(n)-1)
height = 2*s+3
if s==0 and n=='0':
print("end")
break
print_number(s, n)
print("")
f.close()
var inputLineList = prompt("글자크기와 출력할 숫자 목록(2 12345/3 67890)", "2 12345/3 67890").split("/");
var lineIdx = 0;
while(lineIdx < inputLineList.length){
var input = inputLineList[lineIdx].split(" ");
var printPrototype = new Array(" "," ── ","│ │"," │","│ ");
var printDesign = new Array(5);
printDesign[0] = new Array(1,0,1,1,0,1,1,1,1,1);
printDesign[1] = new Array(2,3,3,3,2,4,4,2,2,2);
printDesign[2] = new Array(0,0,1,1,1,1,1,0,1,1);
printDesign[3] = new Array(2,3,4,3,3,3,2,3,2,3);
printDesign[4] = new Array(1,0,1,1,0,1,1,0,1,1);
var textSize = 1;
for(var i = 0; i <= 4; i++){
if(i == 1 || i == 3)
textSize = input[0];
while(textSize-- > 0){
for(var j = 0; j < input[1].length; j++){
var nowNum = input[1].charAt(j);
document.write(printPrototype[printDesign[i][nowNum]] + " ");
}
document.write("<br>");
}
textSize = 1;
}
document.write("<br>");
lineIdx++;
}
문제 감사합니다
c언어로 작성, 파일 IO는 생략한다.
#include <stdio.h>
void printDigit(int s, int* n, int cnt){
int digit[10][5] =
{{1,4,4,4,1},{0,3,3,3,0},{1,3,1,2,1},{1,3,1,3,1},{0,4,1,3,0},{1,2,1,3,1},{1,2,1,4,1},{1,3,0,3,0},{1,4,1,4,1},{1,4,1,3,1}};
char h[3] = {' ',' ',' '};
int vcnt = 1;
for(int i = 0; i < 5; i++){
vcnt = (i == 1 || i == 3) ? s : 1;
for(int j = 0; j < vcnt; j++){
for(int d = 0; d < cnt; d++){
h[0] = ' '; h[1] = ' '; h[2] = ' ';
switch(digit[n[d]][i]){
case 0:
break;
case 1:
h[1] = '-';
break;
case 2:
h[0] = '|';
break;
case 3:
h[2] = '|';
break;
case 4:
h[0] = '|';
h[2] = '|';
break;
}
printf("%c",h[0]);
for(int k = 0; k < s; k++){
printf("%c",h[1]);
}
printf("%c",h[2]);
printf(" ");
}
printf("\n");
}
}
printf("\n");
}
int main(){
int in1[5] = {1, 2, 3, 4, 5};
int in2[5] = {6, 7, 8, 9, 0};
printDigit(2, in1, 5);
printDigit(3, in2, 5);
}
D:\16.minGW>gcc a.c
D:\16.minGW>a
-- -- --
| | | | | |
| | | | | |
| -- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
D:\16.minGW>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void pWidth(int s);
void pHeight(int s, char val);
int getSize(int val);
struct Info {
char* info;
} i[10];
void main(void) {
int input = 0;
int nSize;
int size = 0;
scanf("%d %d",&size, &input);
nSize = getSize(input);
i[0].info = "wb bw";
i[1].info = " r r ";
i[2].info = "wrwlw";
i[3].info = "wrwrw";
i[4].info = " bwr ";
i[5].info = "wlwrw";
i[6].info = "wlwbw";
i[7].info = "wr r ";
i[8].info = "wbwbw";
i[9].info = "wbwrw";
printf("size : %d\n", size);
int wtemp = input;
int htemp = input;
for(int p = 0; p<5 ; p++) {
wtemp = input;
if(p%2 == 0) {
for(int q = nSize; q>=0 ;q--) {
int n = wtemp / (int)pow(10.0, q);
if(i[n].info[p] =='w')
pWidth(size);
else {
for(int r=0;r<=size+1;r++)
printf(" ");
}
printf(" ");
wtemp = wtemp - wtemp/(int)pow(10.0, q) * (int)pow(10.0, q);
}
printf("\n");
}
else {
for(int q = 0; q < size ;q++) {
htemp = input;
for(int r = nSize; r>=0 ;r--) {
int n = htemp / (int)pow(10.0, r);
if(i[n].info[p] == 'r')
pHeight(size, 'r');
if(i[n].info[p] == 'l')
pHeight(size, 'l');
if(i[n].info[p] == 'b')
pHeight(size, 'b');
htemp = htemp - htemp/(int)pow(10.0, r) * (int)pow(10.0, r);
printf(" ");
}
printf("\n");
}
}
}
}
void pWidth(int s) {
printf(" ");
for(int i = 0;i<s; i++) {
printf("-");
}
printf(" ");
}
void pHeight(int s, char val) {
if(val == 'b') {
printf("|");
for(int j = 0;j<s; j++)
printf(" ");
printf("|");
}
else if(val == 'r') {
for(int j = 0;j<s; j++)
printf(" ");
printf(" |");
}
else if(val == 'l') {
printf("|");
for(int j = 0;j<=s; j++)
printf(" ");
}
}
int getSize(int val) {
int size = 0;
int i = 1;
while(val/i != 0) {
i= i*10;
size++;!
}
return size-1;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <string>
using namespace std;
class num {
private:
int s; string n;
public:
num(int cs, string cn):s(cs),n(cn){}
void ub();
void b();
void lb();
void rb();
void bb();
void output();
};
void num::ub() {
printf(" ");
for (int i = 0; i < s; i++) {
printf("-");
}
printf(" ");
}
void num::b() {
printf(" ");
for (int i = 0; i < s; i++) {
printf(" ");
}
printf(" ");
}
void num::lb() {
printf("|");
for (int i = 0; i < s; i++) {
printf(" ");
}
printf(" ");
}
void num::rb() {
printf(" ");
for (int i = 0; i < s; i++) {
printf(" ");
}
printf("|");
}
void num::bb() {
printf("|");
for (int i = 0; i < s; i++) {
printf(" ");
}
printf("|");
}
void num::output() {
for (int i = 0; i < (2 * s) + 3; i++) {
for (int j = 0; j < n.size(); j++) {
if(i == 0){
if (n[j] == '1' || n[j] == '4')
b();
else
ub();
}
else if (i>0 && i<s+1) {
if (n[j] == '0' || n[j] == '4' || n[j] == '8' || n[j] == '9')
bb();
else if (n[j] == '5' || n[j] == '6')
lb();
else
rb();
}
else if (i == s+1) {
if (n[j] == '0' || n[j] == '1' || n[j] == '7')
b();
else
ub();
}
else if (i> s+1 && i<(2*s)+2) {
if (n[j] == '2')
lb();
else if (n[j] == '0' || n[j] == '6' || n[j] == '8')
bb();
else
rb();
}
else if (i == (2 * s) + 2) {
if (n[j] == '1' || n[j] == '4' || n[j] == '7')
b();
else
ub();
}
cout << " ";
}
cout << endl;
}
}
int main(void) {
int s; string n;
while (1) {
cout << "s 와 공백구분 후 n 차례로 입력 : ";
cin >> s >> n;
if (s == 0 && n == "0") {
break;
}
num x(s, n);
x.output();
}
system("pause");
return 0;
}
처음에는 하나하나 함수로 지정해서 엄청 뚱뚱한 코드가 되어버렸습니다.
def one(s):
one = []
a = ' '*(s+2)
b = ' '*(s+1) + '|'
one.append(a)
for i in range(s): one.append(b)
one.append(a)
for i in range(s): one.append(b)
one.append(a)
return one
def two(s):
two = []
a = ' ' + '-'*s + ' '
b = ' '*(s+1) + '|'
c = '|' + ' '*(s+1)
two.append(a)
for i in range(s): two.append(b)
two.append(a)
for i in range(s): two.append(c)
two.append(a)
return two
def three(s):
three = []
a = ' ' + '-'*s + ' '
b = ' '*(s+1) + '|'
three.append(a)
for i in range(s): three.append(b)
three.append(a)
for i in range(s): three.append(b)
three.append(a)
return three
def four(s):
four = []
a = ' '*(s+2)
b = '|' + ' '*s + '|'
c = ' ' + '-'*s + ' '
d = ' '*(s+1) + '|'
four.append(a)
for i in range(s): four.append(b)
four.append(c)
for i in range(s): four.append(d)
four.append(a)
return four
def five(s):
five = []
a = ' ' + '-'*s + ' '
b = ' '*(s+1) + '|'
c = '|' + ' '*(s+1)
five.append(a)
for i in range(s): five.append(c)
five.append(a)
for i in range(s): five.append(b)
five.append(a)
return five
def six(s):
six = []
a = ' ' + '-'*s + ' '
b = '|' + ' '*(s+1)
c = '|' + ' '*s + '|'
six.append(a)
for i in range(s): six.append(b)
six.append(a)
for i in range(s): six.append(c)
six.append(a)
return six
def seven(s):
seven = []
a = ' ' + '-'*s + ' '
b = ' '*(s+1) + '|'
c = ' '*(s+2)
seven.append(a)
for i in range(s): seven.append(b)
seven.append(c)
for i in range(s): seven.append(b)
seven.append(c)
return seven
def eight(s):
eight = []
a = ' ' + '-'*s + ' '
b = '|' + ' '*s + '|'
eight.append(a)
for i in range(s): eight.append(b)
eight.append(a)
for i in range(s): eight.append(b)
eight.append(a)
return eight
def nine(s):
nine = []
a = ' ' + '-'*s + ' '
b = '|' + ' '*s + '|'
c = ' '*(s+1) + '|'
nine.append(a)
for i in range(s): nine.append(b)
nine.append(a)
for i in range(s): nine.append(c)
nine.append(a)
return nine
def zero(s):
zero = []
a = ' ' + '-'*s + ' '
b = '|' + ' '*s + '|'
c = ' '*(s+2)
zero.append(a)
for i in range(s): zero.append(b)
zero.append(c)
for i in range(s): zero.append(b)
zero.append(a)
return zero
s,n = 1,1
while (s!=0) and (n!=0):
s = int(input("Enter a size: "))
n = input("Enter a number: ")
if (s==0) and (n==0): break
ALL = []
for i in n:
if int(i) == 1: ALL.append(one(s))
elif int(i) == 2: ALL.append(two(s))
elif int(i) == 3: ALL.append(three(s))
elif int(i) == 4: ALL.append(four(s))
elif int(i) == 5: ALL.append(five(s))
elif int(i) == 6: ALL.append(six(s))
elif int(i) == 7: ALL.append(seven(s))
elif int(i) == 8: ALL.append(eight(s))
elif int(i) == 9: ALL.append(nine(s))
else: ALL.append(zero(s))
for i in range(2*s + 3):
for j in range(len(n)):
print(ALL[j][i],end=' ')
print()
six함수 정의할 때 쯤부터 생각해보니 뭔가 겹치는 애들이 많아서 합칠 수 있을 것 같단 생각이 들더라구요.
그래서 아래와 같이 작성해보았습니다.
table = [
['14','23567890'], #space vs row
['56','4890','1237'], #left vs double vs right
['170','2345689'], #space vs row
['2','680','134579'], #left vs double vs right
['147','2356890']] #space vs row
s,n = 1,1
while (s!=0) and (n!=0):
s,n = input().split(' ')
if (s==0) and (n==0):
break
s = int(s)
for t in range(5):
if (t==0) or (t==2) or (t==4):
for i in n:
if i in table[t][0]: print("{}".format(' '*(s+2)),end=' ')
else: print(" {} ".format('-'*s),end=' ')
print()
else:
for j in range(s):
for i in n:
if i in table[t][0]: print("|{}".format(' '*(s+1)),end=' ')
elif i in table[t][1]: print("|{}|".format(' '*s),end=' ')
else: print("{}|".format(' '*(s+1)),end=' ')
print()
어째 hwang님이랑 비슷해져버렸네요...
파이썬 초보입니다ㅠ 많은 피드백 부탁드려요
public class question {
static int[] num;
Y1 y1; X1 x1; Y2 y2; X2 x2; Y3 y3;
public static void main(String[] args)
{
question a = new question();
Scanner input = new Scanner(System.in);
while(true)
{
System.out.println("숫자크기(1~9), 0~999999999중 숫자 하나 입력. 0,0을 입력 시 프로그램 종료.\n중간은 공백처리.");
int s= input.nextInt();
int n = input.nextInt();
if (s == 0 && n ==0)
{
System.out.println("프로그램을 종료합니다.");
break;
}
int n_length = (""+n).length();
a.bunhal(n, n_length);
a.draw(s, n_length, num);
}
}
void bunhal(int n, int n_length)
{
num = new int[n_length];
for (int i = n_length-1 ; i>=0 ; i--)
{
num[i] = n/(int)(Math.pow(10, n_length-1-i))%10;
// System.out.println(num[i]);
}
}
void draw(int s, int num_length, int[] num_m)
{
for (int i=1 ; i <= num_length ; i++)
{
y1 = new Y1(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
for (int i=1 ; i <=num_length ; i++)
{
x1 = new X1(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
for (int i=1 ; i <=num_length ; i++)
{
x1 = new X1(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
for (int i=1 ; i <= num_length ; i++)
{
y2 = new Y2(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
for (int i=1 ; i <= num_length ; i++)
{
x2 = new X2(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
for (int i=1 ; i <= num_length ; i++)
{
x2 = new X2(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
for (int i=1 ; i <= num_length ; i++)
{
y3 = new Y3(num_m[i-1], s);
System.out.print(" ");
}
System.out.print("\n");
System.out.print("\n");
}
}
class Y1
{
public Y1(int num, int s)
{
if (num == 1 || num == 4)
{
for (int i=1 ; i <=s+2 ; i++)
{
System.out.print(" ");
}
}
else
{
System.out.print(" ");
for (int i=1 ; i <=s ; i++)
{
System.out.print("-");
}
System.out.print(" ");
}
}
}
class X1
{
public X1(int num, int s)
{
if (num == 1 || num ==3 || num == 7 || num ==2)
{
for (int i=1 ; i <=s+1 ; i++)
{
System.out.print(" ");
}
System.out.print("|");
}
else if (num == 4 || num >= 8 || num == 0)
{
System.out.print("|");
for (int i=1 ; i <=s ; i++)
{
System.out.print(" ");
}
System.out.print("|");
}
else
{
System.out.print("|");
for (int i=1 ; i <=s+1 ; i++)
{
System.out.print(" ");
}
}
}
}
class Y2
{
public Y2(int num, int s)
{
if (num == 1 || num ==7 || num == 0)
{
for (int i=1 ; i <=s+2 ; i++)
{
System.out.print(" ");
}
}
else
{
System.out.print(" ");
for (int i=1 ; i <=s ; i++)
{
System.out.print("-");
}
System.out.print(" ");
}
}
}
class X2
{
public X2(int num, int s)
{
if (num == 1 || num ==3 || num == 4 || num ==5 || num ==7 || num == 9)
{
for (int i=1 ; i <=s+1 ; i++)
{
System.out.print(" ");
}
System.out.print("|");
}
else if (num == 6 || num == 8 || num == 0)
{
System.out.print("|");
for (int i=1 ; i <=s ; i++)
{
System.out.print(" ");
}
System.out.print("|");
}
else
{
System.out.print("|");
for (int i=1 ; i <=s+1 ; i++)
{
System.out.print(" ");
}
}
}
}
class Y3
{
public Y3(int num, int s)
{
if (num == 1 || num ==7 || num == 4)
{
for (int i=1 ; i <=s+2 ; i++)
{
System.out.print(" ");
}
}
else
{
System.out.print(" ");
for (int i=1 ; i <=s ; i++)
{
System.out.print("-");
}
System.out.print(" ");
}
}
}
다른분들 너무 대단하시네요..
Bit 스트링으로 Mask를 설정하고, 해당 Row에서 Bit 연산하여 출력여부 결정하는 방법으로 풀어봤습니다.
public class LCDDisplay {
public static void main(String[] args) {
new LCDDisplay().printLCDDisplay(2, "0123456789");
}
public void printLCDDisplay(final int size, final String numbers) {
Integer[] bitMask = { Integer.parseInt("1110111" , 2), Integer.parseInt("0100100" , 2), Integer.parseInt("1011101" , 2), Integer.parseInt("1101101" , 2),
Integer.parseInt("0101110" , 2), Integer.parseInt("1101011" , 2), Integer.parseInt("1111011" , 2), Integer.parseInt("0100101" , 2),
Integer.parseInt("1111111" , 2), Integer.parseInt("1101111" , 2) };
final int row = 2 * size + 3;
final int col = size + 2;
final int mid = row / 2;
char[][] lcd = new char[row][col * numbers.length() + (numbers.length() - 1)];
for(int numberIndex = 0; numberIndex < numbers.length(); numberIndex++) {
int mask = bitMask[numbers.charAt(numberIndex) - '0'];
final int startCol = (numberIndex * col) + (numberIndex);
final int endCol = (numberIndex * col) + (numberIndex) + col;
for(int rowIndex = 0; rowIndex < row; rowIndex++) {
// 상
if(rowIndex == 0 && (mask & 1) == 1) {
for(int colIndex = startCol + 1; colIndex < endCol - 1; colIndex++) {
lcd[rowIndex][colIndex] = '-';
}
}
// 하
else if(rowIndex == row - 1 && ((mask >> 6) & 1) == 1) {
for(int colIndex = startCol + 1; colIndex < endCol - 1; colIndex++) {
lcd[rowIndex][colIndex] = '-';
}
}
else if(rowIndex > 0 &&rowIndex < mid) {
// 좌상
if(((mask >> 1) & 1) == 1) {
lcd[rowIndex][startCol] = '|';
}
// 우상
if(((mask >> 2) & 1) == 1) {
lcd[rowIndex][endCol - 1] = '|';
}
}
else if(rowIndex == mid) {
if(((mask >> 3) & 1) == 1) {
for(int colIndex = startCol + 1; colIndex < endCol - 1; colIndex++) {
lcd[rowIndex][colIndex] = '-';
}
}
}
else if(rowIndex < row - 1 && rowIndex > mid) {
// 좌하
if(((mask >> 4) & 1) == 1) {
lcd[rowIndex][startCol] = '|';
}
// 우하
if(((mask >> 5) & 1) == 1) {
lcd[rowIndex][endCol - 1] = '|';
}
}
}
}
for(int i = 0; i < lcd.length; i++) {
for(int j = 0; j < lcd[0].length; j++) {
System.out.print(lcd[i][j]);
}
System.out.println();
}
}
}
#include <iostream>
using namespace std;
char numbers[10][7]={
{'-','|','|',' ','|','|','-'},
{' ',' ','|',' ',' ','|',' '},
{'-',' ','|','-','|',' ','-'},
{'-',' ','|','-',' ','|','-'},
{' ','|','|','-',' ','|',' '},
{'-','|',' ','-',' ','|','-'},
{'-','|',' ','-','|','|','-'},
{'-','|','|',' ',' ','|',' '},
{'-','|','|','-','|','|','-'},
{'-','|','|','-',' ','|','-'}
};
int main()
{
int s,n;
int length=0;
int nums[8];
int index =0;
do{
cin<<s<<n;
if(n==0)nums[length++]=0;
while(n!=0){
nums[length]=n%10;
length++;
n/=10;
}
for(int i=0;i<5;i++){
for(int z=0;z<=(index%3)*(s-1);z++){
for(int j=1;j<=length;j++){
switch(index){
case 0:
case 3:
case 6:
cout<<" ";
for(int x=0;x<s;x++) cout<<numbers[nums[length-j]][index];
cout<<" ";
break;
case 1:
case 4:
cout<<numbers[nums[length-j]][index];
for(int x=0;x<s;x++) cout<<" ";
cout<<numbers[nums[length-j]][index+1]<<" ";
break;
}
}
if(index%3!=0)cout<<endl;
}
if(index%3==0)cout<<endl;
if(index==1||index==4) index++;
index++;
}
}while(s==0&&n==0);
return 0;
}
C++ 기초배운걸로만 만들어봤습니다.. 몇시간동안 생각했는데.. 진짜 다들 대단하시네요...
특이하게 허접한 코드 대량생산하는 사람입니다
#include <stdio.h>
void printUpper(char(*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s ; i++)
{
myArray[0][i + accumul] = '-';
}
}
void printMid(char (*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s; i++)
{
myArray[s+1][i + accumul] = '-';
}
}
void printBottom(char(*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s; i++)
{
myArray[2 * s + 2][i + accumul] = '-';
}
}
void printLeftUpper(char(*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s; i++)
{
myArray[i][accumul] = '|';
}
}
void printLeftBottom(char(*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s; i++)
{
myArray[i + s + 1][accumul] = '|';
}
}
void printRightUpper(char(*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s; i++)
{
myArray[i][accumul + s + 1] = '|';
}
}
void printRightBottom(char(*myArray)[100], int s, int accumul)
{
int i = 0;
for (i = 1; i <= s; i++)
{
myArray[i + s + 1][accumul + s + 1] = '|';
}
}
int main(void)
{
char myArray[100][100] = { ' ' };
int length = 0;
int i = 0;
int s = 0;
int accumul = 0;
char string[1024] = { '\0' };
scanf_s("%d %s", &s, string, sizeof(string));
for ( i = 0; string[i] != '\0' ; i++)
{
switch (string[i])
{
case '0':
printBottom(myArray, s, accumul);
printUpper(myArray, s, accumul);
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
printLeftBottom(myArray, s, accumul);
printLeftUpper(myArray, s, accumul);
break;
case '1':
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
break;
case '2':
printBottom(myArray, s, accumul);
printUpper(myArray, s, accumul);
printMid(myArray, s, accumul);
printRightUpper(myArray, s, accumul);
printLeftBottom(myArray, s, accumul);
break;
case '3':
printBottom(myArray, s, accumul);
printUpper(myArray, s, accumul);
printMid(myArray, s, accumul);
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
break;
case '4':
printLeftUpper(myArray, s, accumul);
printMid(myArray, s, accumul);
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
break;
case '5':
printBottom(myArray, s, accumul);
printUpper(myArray, s, accumul);
printMid(myArray, s, accumul);
printLeftUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
break;
case '6':
printBottom(myArray, s, accumul);
printMid(myArray, s, accumul);
printLeftUpper(myArray, s, accumul);
printLeftBottom(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
break;
case '7':
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
printUpper(myArray, s, accumul);
break;
case '8':
printBottom(myArray, s, accumul);
printUpper(myArray, s, accumul);
printMid(myArray, s, accumul);
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
printLeftBottom(myArray, s, accumul);
printLeftUpper(myArray, s, accumul);
break;
case '9':
printUpper(myArray, s, accumul);
printMid(myArray, s, accumul);
printLeftUpper(myArray, s, accumul);
printRightUpper(myArray, s, accumul);
printRightBottom(myArray, s, accumul);
break;
}
accumul += s + 3;
}
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 100; j++)
{
printf("%c", myArray[i][j]);
}
printf("\n");
}
return 0;
}
c로 작성
문자열 사용 X
함수 사용 X
#include<stdio.h>
int main(void)
{
int s, n, set, count, exponent, divide_set, i, exponent_memory, temporary_count,f;
while (1)
{
scanf("%d %d", &s, &n);
count = 0;
exponent = 1;
if (s == 0 && n == 0)
break;
else
{
set = n;
while (set > 0)
{
set /= 10;
count++;
}
if (n == 0)
count++;
f = temporary_count = count;
while (count> 0)
{
exponent *= 10;
count--;
}
exponent_memory = exponent/10;
count = (2 * s + 3);
while (count > 0)
{
set = n;
exponent = exponent_memory;
f = temporary_count;
while (set > 0 || f>0)
{
divide_set = set / exponent;
if (count == (2 * s + 3))
{
if (divide_set == 2 || divide_set == 3 || divide_set == 5 || divide_set == 6 || divide_set == 7 || divide_set == 8 || divide_set == 9 || divide_set == 0)
{
for (i = 1; i <= s + 2; i++)
{
if (i == 1 || i == s + 2)
printf("%c", ' ');
else
printf("%c", '-');
}
}
else
for (i = 1; i <= s + 2; i++)
printf("%c", ' ');
printf(" ");
}
else if (count > (2 * s + 3)/2 + 1)
{
if (divide_set == 1 || divide_set == 2 || divide_set == 3 || divide_set == 7)
{
for (i = 1; i <= s + 2; i++)
{
if (i == s + 2)
printf("%c", '|');
else
printf("%c", ' ');
}
}
else if (divide_set == 5 || divide_set == 6)
for (i = 1; i <= s + 2; i++)
{
if (i == 1)
printf("%c", '|');
else
printf(" ");
}
else
for (i = 1; i <= s + 2; i++)
{
if (i == 1 || i == s + 2)
printf("|");
else
printf(" ");
}
printf(" ");
}
else if (count == (2 * s + 3) / 2 + 1)
{
if (divide_set == 2 || divide_set == 3 || divide_set == 4 || divide_set == 5 || divide_set == 6 || divide_set == 8 || divide_set == 9)
{
for (i = 1; i <= s + 2; i++)
{
if (i == 1 || i == s + 2)
printf("%c", ' ');
else
printf("%c", '-');
}
}
else
for (i = 1; i <= s + 2; i++)
printf("%c", ' ');
printf(" ");
}
else if (count > 1)
{
if (divide_set == 1 || divide_set == 3 || divide_set == 4 || divide_set == 5 || divide_set == 7 || divide_set == 9)
for (i = 1; i <= s + 2; i++)
{
if (i == s + 2)
printf("|");
else
printf(" ");
}
else if (divide_set == 2)
for (i = 1; i <= s + 2; i++)
{
if (i == 1)
printf("|");
else
printf(" ");
}
else
for (i = 1; i <= s + 2; i++)
{
if (i == 1 || i == s + 2)
printf("|");
else
printf(" ");
}
printf(" ");
}
else
{
if (divide_set == 2 || divide_set == 3 || divide_set == 5 || divide_set == 6 || divide_set == 8 || divide_set == 9 || divide_set == 0)
{
for (i = 1; i <= s + 2; i++)
{
if (i == 1 || i == s + 2)
printf("%c", ' ');
else
printf("%c", '-');
}
}
else
for (i = 1; i <= s + 2; i++)
printf("%c", ' ');
printf(" ");
}
set %= exponent;
exponent /= 10;
f--;
}
printf("\n");
count--;
}
}
}
}
s,n = input().split()
s = int(s)
# 미리 각 숫자들마다 들어가는 라인에 대해 표현
num_dict = {'1':[0,0,1,0,0,1,0],
'2':[1,0,1,1,1,0,1],
'3':[1,0,1,1,0,1,1],
'4':[0,1,1,1,0,1,0],
'5':[1,1,0,1,0,1,1],
'6':[1,1,0,1,1,1,1],
'7':[1,0,1,0,0,1,0],
'8':[1,1,1,1,1,1,1],
'9':[1,1,1,1,0,1,1],
'0':[1,1,1,0,1,1,1]}
# [0]
# -----
# l l
# l l
# l[1] l[2]
# l l
# l [3] l
# -----
# l l
# l l
# l[4] l[5]
# l l
# l [6] l
# -----
num = 0 # 숫자별 리스트에 index참조를 위한 숫자?
switch = 0 # 세로출력 2번까지만 해주는 스위치 변수
while True: # 단순 반복을 위한 while문
for val in n: # 가로열 출력 반복문
if num_dict[val][num] == True: # 상 or 중 or 하 가로열이 있다 없다 판가름.
print(' ','-'*s,' ',sep='',end='')
else:
print(' '*(s+3),end='')
num += 1
print()
if switch == 2: # 3번째 세로열 출력하지 못하게 하는 while 탈출
break
for i in range(s): # 세로열 출력을 위한 반복문
for val in n: # 각 문자마다 [1],[2] or [4],[5] 라인이 있는지 없는지 다르기에 하나씩 뽑는다.
if num_dict[val][num] == True: # [1],[4]라인
print('l',' '*s,sep='',end='')
else:
print(' '*(s+1),end='')
if num_dict[val][num+1] == True:# [2],[5]라인
print('l',end=' ')
else:
print(' ',end=' ')
print()
num += 2 # 세로 한번출력할때마다 2개라인씩 잡아먹기때문에 +2
switch += 1 # 가로한번 세로한번 출력하면 +1
#### 2016.12.02 D-447 ####
한줄씩 계산해서 출력해나갑니다. :-)
function scan(i, size, d) {
if (i == 0) {
if ("02356789".indexOf(d) != -1)
return ` ${"-".repeat(size)} `;
else
return ` ${" ".repeat(size)} `;
} else if (i < size + 1) {
let bars = [("045689".indexOf(d) != -1) ? "|" : " ",
("01234789".indexOf(d) != -1) ? "|" : " "]
return bars.join(" ".repeat(size));
} else if (i == size + 1) {
if ("2345689".indexOf(d) != -1)
return ` ${"-".repeat(size)} `;
else
return ` ${" ".repeat(size)} `;
} else if (i < size * 2 + 2) {
let bars = [("0268".indexOf(d) != -1) ? "|" : " ",
("013456789".indexOf(d) != -1) ? "|" : " "]
return bars.join(" ".repeat(size));
} else {
if ("0235689".indexOf(d) != -1)
return ` ${"-".repeat(size)} `;
else
return ` ${" ".repeat(size)} `;
}
}
const size = 5;
const ds = "0123456789";
const height = size * 2 + 3;
for (let i = 0; i < height; i++) {
console.log(ds.split("").map(d => scan(i, size, d)).join(" "))
}
#encoding=utf-8
#python3.5
#codingdojang314
#파이썬에서 공백을 기준으로 입력값을 구분하는 방법 필요
size,count = input()
strCount = str(count)
for num in strCount:
print(num)
if int(num) == 1:
for i in range(1,3):
print("")
for j in range(1,size+1):
print("{0:^{1}}".format('|',size+1))
print("{0:^{1}}".format('',size+1))
elif int(num) == 2:
for i in range(1,3):
print("-"*size)
for j in range(1,size+1):
if i == 1:
print("{0:>{1}}".format('|',size+1))
else:
print("{0:<{1}}".format('|',size+1))
print("-"*size)
elif int(num) == 3:
for i in range(1,3):
print("-"*size)
for j in range(1,size+1):
print("{0:>{1}}".format('|',size+1))
print("-"*size)
elif int(num) == 4:
for i in range(1,3):
if i == 1:
for j in range(1,size+1):
print("{0:<{1}}".format('|',size+1)+'|')
if i == 2:
print("-"*size)
for j in range(1,size+1):
print("{0:>{1}}".format('|',size+1))
elif int(num) == 5:
for i in range(1,3):
print("-"*size)
for j in range(1,size+1):
if i == 1:
print("{0:<{1}}".format('|',size+1))
else:
print("{0:>{1}}".format('|',size+1))
print("-"*size)
elif int(num) == 6:
for i in range(1,3):
print("-"*size)
for j in range(1,size+1):
if i == 1:
print("{0:<{1}}".format('|',size+1))
else:
print("|"+"{0:>{1}}".format('|',size+1))
print("-"*size)
elif int(num) == 7:
for i in range(1,3):
if i == 1:
print("-"*size)
else:
print("")
for j in range(1,size+1):
print("{0:>{1}}".format('|',size+1))
print("{0:>{1}}".format('',size+1))
elif int(num) == 8:
for i in range(1,3):
print("-"*size)
for j in range(1,size+1):
if i == 1:
print("|"+"{0:>{1}}".format('|',size+1))
else:
print("|"+"{0:>{1}}".format('|',size+1))
print("-"*size)
elif int(num) == 9:
for i in range(1,3):
print("-"*size)
for j in range(1,size+1):
if i == 1:
print("|"+"{0:>{1}}".format('|',size+1))
else:
print("{0:>{1}}".format('|',size+1))
print("-"*size)
elif int(num) == 0:
for i in range(1,3):
if i == 2:
print("")
else:
print("-"*size)
for j in range(1,size+1):
if i == 1:
print("|"+"{0:>{1}}".format('|',size+1))
else:
print("|"+"{0:>{1}}".format('|',size+1))
print("-"*size)
elif num == 0 and size == 0:
print("this is END")
numDic = {0:['-', '|', '|', ' ', '|', '|', '-'],\
1:[' ', ' ', '|', ' ', ' ', '|', ' '],\
2:['-', ' ', '|', '-', '|', ' ', '-'],\
3:['-', ' ', '|', '-', ' ', '|', '-'],\
4:[' ', '|', '|', '-', ' ', '|', ' '],\
5:['-', '|', ' ', '-', ' ', '|', '-'],\
6:['-', '|', ' ', '-', '|', '|', '-'],\
7:['-', ' ', '|', ' ', ' ', '|', ' '],\
8:['-', '|', '|', '-', '|', '|', '-'],\
9:['-', '|', '|', '-', ' ', '|', '-']}
def lcd(num, s):
num = str(num)
result = ['' for iter in range(5)]
for i in num:
x = numDic[int(i)]
x1 = ' '+s*x[0]+' '
x2 = x[1]+s*' '+x[2]+' '
x3 = ' '+s*x[3]+' '
x4 = x[4]+s*' '+x[5]+' '
x5 = ' '+s*x[6]+' '
xList = [x1, x2, x3, x4, x5]
for i in range(len(result)):
result[i] += xList[i]
print(result[0])
for i in range(s):
print(result[1])
print(result[2])
for i in range(s):
print(result[3])
print(result[4])
파이썬을 저급하게 만드는 코딩입니다.
import re
# digit from 0 to 9
d = ( (1, 1, 1, 0, 1, 1, 1),
(0, 0, 1, 0, 0, 1, 0),
(1, 0, 1, 1, 1, 0, 1),
(1, 0, 1, 1, 0, 1, 1),
(0, 1, 1, 1, 0, 1, 0),
(1, 1, 0, 1, 0, 1, 1),
(1, 1, 0, 1, 1, 1, 1),
(1, 0, 1, 0, 0, 1, 0),
(1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 0, 1, 1) )
while True:
# Input
InputStr = input()
# Inspect input values
if not re.match(r"\d+\s\d+", InputStr):
continue
InputValues = InputStr.split(' ')
s = int(InputValues[0])
nStr = InputValues[1]
n = int(nStr)
l = len(nStr)
if s == 0 and n == 0:
break
if (s < 1 or s >= 10) or (n < 0 or n > 99999999):
continue
# Prepare empty screen matrix
cols = s + 2
ncols = (cols + 1) * l
rows = s * 2 + 3
scrmtrx = [[' ' for col in range(ncols)] for row in range(rows)]
# Fill the screen matrix with numbers
for i in range(l): # each digit of number n
for j in range(7):
num = int(nStr[i])
shift = (cols + 1) * i
if d[num][j] :
for k in range(s):
if j == 0:
scrmtrx[0][shift+1+k] = '-'
elif j == 1:
scrmtrx[1+k][shift] = '|'
elif j == 2:
scrmtrx[1+k][shift+s+1] = '|'
elif j == 3:
scrmtrx[s+1][shift+1+k] = '-'
elif j == 4:
scrmtrx[s+2+k][shift] = '|'
elif j == 5:
scrmtrx[s+2+k][shift+s+1] = '|'
else: # j == 6
scrmtrx[2*s+2][shift+1+k] = '-'
# Print LCD
lineStr = ""
for i in range(rows):
for k in range(ncols):
lineStr += scrmtrx[i][k]
print(lineStr)
lineStr = ""
print(" ")
#include <iostream>
#include <vector>
#include <string>
using namespace std;
/* http://codingdojang.com/scode/314
LCD Display
한 친구가 방금 새 컴퓨터를 샀다. 그 친구가 지금까지 샀던 가장 강력한 컴퓨터는 공학용 전자 계산기였다.
그런데 그 친구는 새 컴퓨터의 모니터보다 공학용 계산기에 있는 LCD 디스플레이가 더 좋다며 크게 실망하고 말았다.
그 친구를 만족시킬 수 있도록 숫자를 LCD 디스플레이 방식으로 출력하는 프로그램을 만들어보자.
입력
입력 파일은 여러 줄로 구성되며 표시될 각각의 숫자마다 한 줄씩 입력된다.
각 줄에는 s와 n이라는 두개의 정수가 들어있으며 n은 출력될 숫자( 0<= n <= 99,999,999 ), s는 숫자를 표시하는 크기( 1<= s < 10 )를 의미한다.
0 이 두 개 입력된 줄이 있으면 입력이 종료되며 그 줄은 처리되지 않는다.
출력
입력 파일에서 지정한 숫자를 수평 방향은 '-' 기호를, 수직 방향은 '|'를 이용해서 LCD 디스플레이 형태로 출력한다.
각 숫자는 정확하게 s+2개의 열, 2s+3개의 행으로 구성된다. 마지막 숫자를 포함한 모든 숫자를 이루는 공백을 스페이스로 채워야 한다.
두 개의 숫자 사이에는 정확하게 한 열의 공백이 있어야 한다.
각 숫자 다음에는 빈 줄을 한 줄 출력한다. 밑에 있는 출력 예에 각 숫자를 출력하는 방식이 나와있다.
예
입력 예
2 12345
3 67890
0 0
출력 예
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
*/
int main() {
int fontSize, inputNumber;
vector<int> vectorFontSize, vectorInputNumber;
// pre-defined structure of each digit
// index number is equal to actual number
/*
----[0]
| |
|[1] |[2]
| |
| |
----[3]
| |
|[4] |[5]
| |
| |
----[6]
*/
int digitArr[10][7] = {
{ 1, 1, 1, 0, 1, 1, 1 }, // 0
{ 0, 0, 1, 0, 0, 1, 0 }, // 1
{ 1, 0, 1, 1, 1, 0, 1 }, // 2
{ 1, 0, 1, 1, 0, 1, 1 }, // 3
{ 0, 1, 1, 1, 0, 1, 0 }, // 4
{ 1, 1, 0, 1, 0, 1, 1 }, // 5
{ 1, 1, 0, 1, 1, 1, 1 }, // 6
{ 1, 0, 1, 0, 0, 1, 0 }, // 7
{ 1, 1, 1, 1, 1, 1, 1 }, // 8
{ 1, 1, 1, 1, 0, 1, 0 } // 9
};
while (true) {
cin >> fontSize >> inputNumber;
if (fontSize == 0 && inputNumber == 0) {
for (unsigned int vectorIdx = 0; vectorIdx < vectorFontSize.size(); vectorIdx++) {
string strInputNumber = to_string(vectorInputNumber[vectorIdx]);
int positionalNumberCount = strInputNumber.length();
int rowSize = 2 * vectorFontSize[vectorIdx] + 3;
int colSize = vectorFontSize[vectorIdx] + 2;
for (int rowIdx = 0; rowIdx < rowSize; rowIdx++) {
cout << endl;
for (int positionalIdx = 0; positionalIdx < positionalNumberCount; positionalIdx++) {
int currentNumber = strInputNumber[positionalIdx] - '0';
for (int colIdx = 0; colIdx < colSize; colIdx++) {
if (rowIdx == 0 || rowIdx == rowSize / 2 || rowIdx == rowSize - 1) {
if (colIdx == 0 || colIdx == colSize - 1) {
cout << ' ';
}
else {
if (rowIdx == 0) {
cout << ((digitArr[currentNumber][0] == 1) ? '-' : ' ');
}
else if (rowIdx == rowSize / 2) {
cout << ((digitArr[currentNumber][3] == 1) ? '-' : ' ');
}
else if (rowIdx == rowSize - 1) {
cout << ((digitArr[currentNumber][6] == 1) ? '-' : ' ');
}
}
}
else {
if (colIdx == 0 || colIdx == colSize - 1) {
if (rowIdx < rowSize / 2) {
if (colIdx == 0) {
cout << ((digitArr[currentNumber][1] == 1) ? '|' : ' ');
}
else if (colIdx == colSize - 1) {
cout << ((digitArr[currentNumber][2] == 1) ? '|' : ' ');
}
}
else if (rowIdx > rowSize / 2) {
if (colIdx == 0) {
cout << ((digitArr[currentNumber][4] == 1) ? '|' : ' ');
}
else if (colIdx == colSize - 1) {
cout << ((digitArr[currentNumber][5] == 1) ? '|' : ' ');
}
}
}
else {
cout << ' ';
}
}
}
cout << ' ';
}
}
cout << endl;
}
break;
}
else {
if (fontSize < 1 || fontSize >= 10) {
cout << "fontSize error" << endl;
break;
}
else if (inputNumber < 0 || inputNumber > 99999999) {
cout << "inputNumber error" << endl;
break;
}
else {
vectorFontSize.push_back(fontSize);
vectorInputNumber.push_back(inputNumber);
}
}
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LCD_DEBUG
#ifdef LCD_DEBUG
#define MSG_OVERFLOW(pstr) \
printf("[ERR] %s is overflow!! %s %s %d\n", \
pstr, __FILE__, __func__, __LINE__)
#define MSG_MEM_ERR \
printf("[ERR] Memory shortage. %s %s %d\n", \
__FILE__, __func__, __LINE__)
#define MSG_EMPTY_STAT \
printf("[ERR] Memory points NULL status already. %s %s %d\n", \
__FILE__, __func__, __LINE__)
#else
#define MSG_OVERFLOW(pstr)
#define MSG_MEM_ERR
#define MSG_EMPTY_STAT
#endif
typedef enum
{
BUF_SIZE = 16,
MAX_SIZE = 10,
MAX_NUM = 99999999
}overflow_e;
typedef struct input_data_information
{
int size;
char num[BUF_SIZE];
}info_t;
static inline int _check_to_escape(int size, int num);
static inline int _check_to_overflow(const char *pstr,
int data, int start, int end);
static inline int _draw_line(int data_1, int data_2, int data_3, int size);
static void *_create_memory(void *ptr, size_t size);
static int _destory_memory(void **ppdel);
static int _draw_horizontal_line(const int (*parr)[7], info_t *pid, int *pidx);
static int _draw_vertical_line(const int (*parr)[7], info_t *pid, int *pidx);
static int _draw_number_to_display(info_t *pid);
///////////////////////////////////////////////////////////////////////////////
static inline int _check_to_escape(int size, int num)
{
return (size == 0 && num == 0) ? -1 : 0;
}
static inline int _check_to_overflow(const char *pstr,
int data, int start, int end)
{
int ret = 0;
if (data < start || data > end)
{
MSG_OVERFLOW(pstr);
ret = -1;
}
return ret;
}
static inline int _draw_line(int data_1, int data_2, int data_3, int size)
{
int i;
printf("%s", data_1 ? "|" : " ");
for (i = 0; i < size; i++)
printf("%s", data_2 ? "-" : " ");
printf("%s", data_3 ? "|" : " ");
return 0;
}
static void *_create_memory(void *ptr, size_t size)
{
void *pnew = realloc(ptr, size);
if (pnew == NULL)
{
MSG_MEM_ERR;
goto error;
}
return pnew;
error :
return NULL;
}
static int _destory_memory(void **ppdel)
{
if (ppdel == NULL)
{
MSG_EMPTY_STAT;
goto error;
}
if (*ppdel)
{
free((void *)*ppdel);
*ppdel = NULL;
}
return 0;
error :
return -1;
}
static int _draw_horizontal_line(const int (*parr)[7], info_t *pid, int *pidx)
{
int i;
int len;
if (pid == NULL)
{
MSG_EMPTY_STAT;
goto error;
}
len = strlen(pid->num);
for (i = 0; i < len; i++)
_draw_line(0, parr[pid->num[i] - '0'][*pidx], 0, pid->size);
(*pidx)++;
printf("\n");
return 0;
error :
return -1;
}
static int _draw_vertical_line(const int (*parr)[7], info_t *pid, int *pidx)
{
int i;
int j;
int len;
if (pid == NULL)
{
MSG_EMPTY_STAT;
goto error;
}
len = strlen(pid->num);
for (i = 0; i < pid->size; i++)
{
for (j = 0; j < len; j++)
{
_draw_line(parr[pid->num[j] - '0'][*pidx], 0,
parr[pid->num[j] - '0'][*pidx + 1], pid->size);
}
printf("\n");
}
(*pidx) += 2;
return 0;
error :
return -1;
}
static int _draw_number_to_display(info_t *pid)
{
int idx = 0;
const int draw_arr[10][7] =
{
{1, 1, 1, 0, 1, 1, 1}, // 0
{0, 0, 1, 0, 0, 1, 0}, // 1
{1, 0, 1, 1, 1, 0, 1}, // 2
{1, 0, 1, 1, 0, 1, 1}, // 3
{0, 1, 1, 1, 0, 1, 0}, // 4
{1, 1, 0, 1, 0, 1, 1}, // 5
{1, 1, 0, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 1, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1}, // 9
};
if (pid == NULL)
{
MSG_EMPTY_STAT;
goto error;
}
if (_draw_horizontal_line(draw_arr, pid, &idx) < 0)
goto error;
if (_draw_vertical_line(draw_arr, pid, &idx) < 0)
goto error;
if (_draw_horizontal_line(draw_arr, pid, &idx) < 0)
goto error;
if (_draw_vertical_line(draw_arr, pid, &idx) < 0)
goto error;
if (_draw_horizontal_line(draw_arr, pid, &idx) < 0)
goto error;
return 0;
error :
return -1;
}
int main(void)
{
int i;
int size = 1;
int num = 1;
int vari_cnt = 0;
char str[BUF_SIZE] = {0 ,};
info_t *pid = NULL;
while (1)
{
scanf("%d %s", &size, str);
num = atoi(str);
if (_check_to_escape(size, num) < 0)
break;
if (_check_to_overflow("Size", size, 1, MAX_SIZE) < 0)
goto error;
if (_check_to_overflow("Number", num, 0, MAX_NUM) < 0)
goto error;
vari_cnt++;
pid = _create_memory((void *)pid, sizeof(info_t) * vari_cnt);
if (pid == NULL)
goto error;
pid[vari_cnt - 1].size = size;
memmove((void *)&pid[vari_cnt - 1].num, (const void *)str, sizeof(str));
}
for (i = 0; i < vari_cnt; i++)
_draw_number_to_display(&pid[i]);
error :
_destory_memory((void **)&pid);
return 0;
}
후,, 제법 까다롭네요 ㅠㅠ c 언어로 작성했습니다.
# 숫자 하나의 패턴 배열
def num_to_disp_arr(s, n):
ptn_top = '-' if [1, 0, 1, 1, 0, 1, 1, 1, 1, 1][n] == 1 else ' '
ptn_mid = '-' if [0, 0, 1, 1, 1, 1, 1, 0, 1, 1][n] == 1 else ' '
ptn_btn = '-' if [1, 0, 1, 1, 0, 1, 1, 0, 1, 1][n] == 1 else ' '
ptn_t_l = '|' if [1, 0, 0, 0, 1, 1, 1, 0, 1, 1][n] == 1 else ' '
ptn_t_r = '|' if [1, 1, 1, 1, 1, 0, 0, 1, 1, 1][n] == 1 else ' '
ptn_b_l = '|' if [1, 0, 1, 0, 0, 0, 1, 0, 1, 0][n] == 1 else ' '
ptn_b_r = '|' if [1, 1, 0, 1, 1, 1, 1, 1, 1, 1][n] == 1 else ' '
disp_arr = []
disp_arr.append(' ' + (ptn_top * (2 * s)) + ' ')
for i in range(s):
disp_arr.append(ptn_t_l + (' ' * (2 * s)) + ptn_t_r)
disp_arr.append(' ' + (ptn_mid * (2 * s)) + ' ')
for i in range(s):
disp_arr.append(ptn_b_l + (' ' * (2 * s)) + ptn_b_r)
disp_arr.append(' ' + (ptn_btn * (2 * s)) + ' ')
return disp_arr
# 한 라인에 대한 출력
def display(s, num_chars):
disp_arr = []
for num_char in num_chars:
nex_num_dis_arr = num_to_disp_arr(s, int(num_char))
if len(disp_arr ) == 0:
disp_arr = nex_num_dis_arr
else:
disp_arr = [l + ' '+ r for l, r in zip(disp_arr, nex_num_dis_arr )]
for line in disp_arr:
print (''.join(line))
input_file = '''2 12345
3 67890
0 0'''
first_line = True
for line in input_file.split('\n'):
s, n = line.split(' ')
if s != '0':
if not first_line:
print('')
first_line = False
display(int(s), n)
private static void displayLCD(int n, String input){
int check[][] = new int[][]{{1,1,1,0,1,1,1}, {0,0,1,0,0,1,0}, {1,0,1,1,1,0,1}, {1,0,1,1,0,1,1}, {0,1,1,1,0,1,0},{1,1,0,1,0,1,1}, {1,1,0,1,1,1,1}, {1,1,1,0,0,1,0}, {1,1,1,1,1,1,1}, {1,1,1,1,0,1,0}};
//top
for(int i=0; i<input.length(); i++){
int digit = input.charAt(i) - '0';
System.out.print(" ");
if(check[digit][0] == 1){
for(int j=0; j<n; j++){
System.out.print("-");
}
}else{
for(int j=0; j<n; j++){
System.out.print(" ");
}
}
System.out.print(" ");
}
System.out.println();
//vertical 1
for(int k=0; k<n; k++){
for(int i=0; i<input.length(); i++){
int digit = input.charAt(i) - '0';
if(check[digit][1] == 1){
System.out.print("|");
}else{
System.out.print(" ");
}
for(int j=0; j<n; j++){
System.out.print(" ");
}
if(check[digit][2] == 1){
System.out.print("|");
}else{
System.out.print(" ");
}
}
System.out.println();
}
//mid
for(int i=0; i<input.length(); i++){
int digit = input.charAt(i) - '0';
System.out.print(" ");
if(check[digit][3] == 1){
for(int j=0; j<n; j++){
System.out.print("-");
}
}else{
for(int j=0; j<n; j++){
System.out.print(" ");
}
}
System.out.print(" ");
}
System.out.println();
//vertical 2
for(int k=0; k<n; k++){
for(int i=0; i<input.length(); i++){
int digit = input.charAt(i) - '0';
if(check[digit][4] == 1){
System.out.print("|");
}else{
System.out.print(" ");
}
for(int j=0; j<n; j++){
System.out.print(" ");
}
if(check[digit][5] == 1){
System.out.print("|");
}else{
System.out.print(" ");
}
}
System.out.println();
}
//bottom
for(int i=0; i<input.length(); i++){
int digit = input.charAt(i) - '0';
System.out.print(" ");
if(check[digit][6] == 1){
for(int j=0; j<n; j++){
System.out.print("-");
}
}else{
for(int j=0; j<n; j++){
System.out.print(" ");
}
}
System.out.print(" ");
}
}
def sbar():
return print(" ",end="")
def hbar():
return print("-",end="")
def vbar():
return print("l",end="")
number = 1
def number(print_number,iteration_number):
if print_number==0:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
sbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
elif print_number==1:
sbar()
for i in range(iteration_number):
sbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
sbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
sbar()
sbar()
elif print_number==2:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
sbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
elif print_number==3:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
elif print_number==4:
sbar()
for i in range(iteration_number):
sbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
sbar()
sbar()
elif print_number==5:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
sbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
elif print_number==6:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
sbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
elif print_number==7:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
sbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
sbar()
sbar()
elif print_number==8:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
elif print_number==9:
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
vbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar(),print()
for i in range(iteration_number):
sbar()
for j in range(iteration_number):
sbar()
vbar(),print()
sbar()
for i in range(iteration_number):
hbar()
sbar()
input_number=input()
input_number=int(input_number)
number(input_number,2)
c로 풀이. 주먹구구식
#include <stdio.h>
void my_print(int num,int line,int size);
int main(void)
{
int s,n,i,j,m[8],size;
while(1)
{
size=0;
j=1;
scanf("%d%d",&s,&n);
if((s==0)&&(n==0)) break;
if (s>10) s=10;
for(i=1;i<=10000000;i*=10) if(n>=i) size++;
for(i=size-1;i>=0;i--)
{
m[i]=(n/j)%10;
j*=10;
}
for(i=0;i<=2*(s+1);i++)
{
for(j=0;j<size;j++) my_print(m[j],i,s);
printf("\n");
}
}
return 0;
}
void my_print(int num,int line,int size)
{
int i;
if((line==0)||(line==size+1)||(line==2*size+2))
{
printf(" ");
if (((num==2)||(num==3)||(num==5)||(num==6)||(num==8)||(num==9))) for(i=0;i<size;i++) printf("-");
else if(((num==4)&&(line==size+1))||((num==7)&&(line==0))||((num==0)&&((line!=size+1)))) for(i=0;i<size;i++) printf("-");
else for(i=0;i<size;i++) printf(" ");
printf(" ");
}
else if((line>0)&&(line<=size))
{
if((num==1)||(num==2)||(num==3)||(num==7))
{
for(i=0;i<=size;i++) printf(" ");
printf("|");
}
else if((num==4)||(num==8)||(num==9)||(num==0))
{
printf("|");
for(i=0;i<size;i++) printf(" ");
printf("|");
}
else
{
printf("|");
for(i=0;i<=size;i++) printf(" ");
}
}
else if(line>size+1)
{
if(num==2)
{
printf("|");
for(i=0;i<=size;i++) printf(" ");
}
else if((num==6)||(num==8)||(num==0))
{
printf("|");
for (i=0;i<size;i++) printf(" ");
printf("|");
}
else
{
for(i=0;i<=size;i++) printf(" ");
printf("|");
}
}
}
한 줄 씩 그렸네요.
// 전자식 숫자 표시 - C#
using System;
using System.Collections.Generic;
namespace Oldisgood
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("숫자의 크기(1~9)와 출력할 숫자(0~99999999)를 입력하십시오.");
List<string> list = new List<string>(); string select;
do
{
select = Console.ReadLine();
list.Add(select);
} while (select != "0 0");
list.Remove("0 0");
foreach (string s in list)
{
int size = int.Parse(s.Split(' ')[0]);
int num = int.Parse(s.Split(' ')[1]);
if (size < 1 || size > 10 || num <= 0 || num > 100000000)
{
Console.WriteLine("지원되지 않는 숫자입니다.");
continue;
}
int digit = 0, n = num;
List<int> nums = new List<int>();
do
{
n /= 10; digit++;
} while (n != 0);
for (int i = 0; i < digit; i++)
{
nums.Add(i == 0 ? (num / (int)Math.Pow(10, digit - 1)) : (num / (int)Math.Pow(10, digit - i - 1) % 10));// 1000 / 1000 1000 / 100 % 10 1000 / 10 % 10
}
foreach (int m in nums)
{
Console.Write(" ");
for (int i = 0; i < size; i++)
if (m == 1 || m == 4)
Console.Write(" ");
else
Console.Write("-");
Console.Write(" ");
}
Console.WriteLine();
for (int i = 0; i < size; i++)
{
foreach (int m in nums)
{
if (m == 5 || m == 6)
{
Console.Write("|");
for (int j = 0; j <= size; j++)
Console.Write(" ");
}
else if (m == 1 || m == 2 || m == 3)
{
for (int j = 0; j <= size; j++)
Console.Write(" ");
Console.Write("|");
}
else
{
Console.Write("|");
for (int j = 0; j < size; j++)
Console.Write(" ");
Console.Write("|");
}
}
Console.WriteLine();
}
foreach (int m in nums)
{
Console.Write(" ");
for (int i = 0; i < size; i++)
if (m == 0 || m == 1 || m == 7)
Console.Write(" ");
else
Console.Write("-");
Console.Write(" ");
}
Console.WriteLine();
for (int i = 0; i < size; i++)
{
foreach (int m in nums)
{
if (m == 2)
{
Console.Write("|");
for (int j = 0; j <= size; j++)
Console.Write(" ");
}
else if (m == 1 || m == 3 || m == 4 || m == 5 || m == 7 || m == 9)
{
for (int j = 0; j <= size; j++)
Console.Write(" ");
Console.Write("|");
}
else
{
Console.Write("|");
for (int j = 0; j < size; j++)
Console.Write(" ");
Console.Write("|");
}
}
Console.WriteLine();
}
foreach (int m in nums)
{
Console.Write(" ");
for (int i = 0; i < size; i++)
if (m == 1 || m == 4 || m == 7)
Console.Write(" ");
else
Console.Write("-");
Console.Write(" ");
}
Console.WriteLine();
}
}
}
}
golang 으로 만들어봤습니다.
// ysoftman
package main
import "fmt"
import "strings"
var table map[int]string
func main() {
var s int
var n string
fmt.Scanf("%d %s", &s, &n)
if s == 0 && n == "0" {
return
}
table = make(map[int]string)
table[0] = "23567890"
table[1] = "456890"
table[2] = "12347890"
table[3] = "2345689"
table[4] = "2680"
table[5] = "134567890"
table[6] = "2356890"
maxline := (2 * s) + 3
fmt.Println("maxline :", maxline)
for row := 0; row < maxline; row++ {
for i := 0; i < len(n); i++ {
idx1, idx2 := getTableIndex(row, maxline)
if idx1 >= 0 {
if strings.Count(table[idx1], string(n[i])) > 0 {
fmt.Printf("%s", makeMark(idx1, s))
} else {
for a := 0; a < s+1; a++ {
fmt.Printf(" ")
}
if idx2 < 0 {
fmt.Printf(" ")
}
}
}
if idx2 >= 0 {
if strings.Count(table[idx2], string(n[i])) > 0 {
fmt.Printf("%s", makeMark(idx2, s))
} else {
fmt.Printf(" ")
}
}
fmt.Printf(" ")
}
fmt.Println()
}
}
func getTableIndex(row int, maxline int) (int, int) {
if row == 0 {
return 0, -1
} else if row == maxline-1 {
return 6, -1
} else if row == maxline/2 {
return 3, -1
} else if row < maxline/2 {
return 1, 2
} else if row > maxline/2 {
return 4, 5
}
return -1, -1
}
func makeMark(idx int, size int) string {
mark := ""
if idx == 0 || idx == 3 || idx == 6 {
mark = " "
for i := 1; i < size+1; i++ {
mark += "-"
}
mark += " "
} else if idx == 1 || idx == 4 {
mark = "|"
for i := 1; i < size+1; i++ {
mark += " "
}
} else if idx == 2 || idx == 5 {
mark = "|"
}
return mark
}
[Python 3.6]
def display_LCD_num(input_file_name):
input_file = open(input_file_name)
for i, inputline in enumerate(input_file.readlines()):
size, numstr = inputline.split(' ')
if size == numstr.strip() == '0':
break
if i != 0: print()
numarray = []
for single_num in numstr.strip():
array = make_LCD_single_num(int(size), int(single_num))
if numarray:
numarray = append_num_array(numarray, array)
else:
numarray = array
for line in numarray:
for row in line:
print(row, end='')
print()
def make_LCD_single_num(size, single_num):
maxrownum = size + 2
maxlinenum = size * 2 + 3
numarray = []
for line in range(maxlinenum):
rowarray = []
for row in range(maxrownum):
if line == 0:
if row == 0 or row == maxrownum - 1:
rowarray.append(' ')
else:
if single_num in (0, 2, 3, 5, 6, 7, 8, 9):
rowarray.append('-')
else:
rowarray.append(' ')
elif line == (maxlinenum - 1) / 2:
if row == 0 or row == maxrownum - 1:
rowarray.append(' ')
else:
if single_num in (2, 3, 4, 5, 6, 8, 9):
rowarray.append('-')
else:
rowarray.append(' ')
elif line == maxlinenum - 1:
if row == 0 or row == maxrownum - 1:
rowarray.append(' ')
else:
if single_num in (0, 2, 3, 5, 6, 8, 9):
rowarray.append('-')
else:
rowarray.append(' ')
elif line < (maxlinenum - 1) / 2:
if row != 0 and row != maxrownum - 1:
rowarray.append(' ')
else:
if row == 0:
if single_num in (0, 4, 5, 6, 8, 9):
rowarray.append('|')
else:
rowarray.append(' ')
else:
if single_num in (0, 1, 2, 3, 4, 7, 8, 9):
rowarray.append('|')
else:
rowarray.append(' ')
else:
if row != 0 and row != maxrownum - 1:
rowarray.append(' ')
else:
if row == 0:
if single_num in (0, 2, 6, 8):
rowarray.append('|')
else:
rowarray.append(' ')
else:
if single_num in (0, 1, 3, 4, 5, 6, 7, 8, 9):
rowarray.append('|')
else:
rowarray.append(' ')
numarray.append(rowarray)
return numarray
def append_num_array(numarray1, numarray2):
for i in range(len(numarray1)):
numarray1[i] += [' '] + numarray2[i]
return numarray1
파이썬 3.6입니다.
num='123456789'; count='2'
num=int(num); count=int(count)
def first_part(num, count) :
print(' ', end='')
if num == 1 or num == 4:
while count > 0 :
print(' ', end='')
count -= 1
else :
while count > 0 :
print('-', end='')
count -= 1
print(' ', end='')
def second_part(num, count) :
if num == 1 or num == 2 or num == 3 or num == 7 :
while count > 1 :
print(' ', end='')
count -= 1
print('|', end='')
elif num == 5 or num == 6 :
print('|', end='')
while count > 1 :
print(' ', end='')
count -= 1
else :
print('|', end='')
while count > 2 :
print(' ', end='')
count -= 1
print('|', end='')
print(' ', end='')
def third_part(num, count) :
print(' ', end='')
if num == 1 or num == 7 or num == 0 :
while count > 0 :
print(' ', end='')
count -= 1
else :
while count > 0 :
print('-', end='')
count -= 1
print(' ', end='')
def fourth_part(num, count) :
if num == 1 or num == 3 or num == 4 or num == 5 or num == 7 or num == 9:
while count > 1 :
print(' ', end='')
count -= 1
print('|', end='')
else :
print('|', end='')
while count > 2 :
print(' ', end='')
count -= 1
print('|', end='')
print(' ', end='')
def fifth_part(num, count) :
print(' ', end='')
if num == 1 or num == 4 or num == 7:
while count > 0 :
print(' ', end='')
count -= 1
else :
while count > 0 :
print('-', end='')
count -= 1
print(' ', end='')
def print_digit(num, count) :
numlist=[]
while num > 0 :
numlist.append(num % 10)
num /= 10
num = int(num)
numlist.reverse()
for j in numlist :
first_part(j, count)
print('')
i = 0
while i < count :
for j in numlist :
second_part(j, count+2)
print('')
i += 1
for j in numlist :
third_part(j, count)
print('')
i = 0
while i < count :
for j in numlist :
fourth_part(j, count+2)
print('')
i += 1
for j in numlist :
fifth_part(j, count)
print('')
print_digit(num, count)
JAVA입니다
public class Ex012 {
static int size;
static int number;
public static void main(String[] args) {
// TODO Auto-generated method stub
while(true) {
//입력
if(!getInputData())
break;
//작업 및 출력
printNumber();
}
}
static private void printNumber() {
String compNum = String.valueOf(number);
byte[][] screen = new byte[2*size+3][compNum.length()*(size+2) + compNum.length() - 1];
int numIdx;
//screen배열에 문자를 출력할 부분을 표시함
//행 탐색
for(int i = 0; i < screen.length; i++) {
numIdx = 0;
//열 탐색
for(int j=0; j < screen[0].length; j+=size+3,numIdx++) {
screen = spray(screen, size+2, 2*size+3, i, j, Integer.valueOf(String.valueOf(compNum.charAt(numIdx))));
}
}
//출력!
for(int i=0; i<screen.length; i++) {
for(int j=0; j<screen[0].length; j++) {
//문자를 출력해야 할 부분이라면,
if(screen[i][j] == 1) {
//'-'를 출력해야하는 행이라면 '-'를, '|'를 출력해야하는 행이라면 '|'를 출력, 나머지는 공백출력
if(i == 0 || i == screen.length/2 || i == screen.length-1)
System.out.print("-");
else
System.out.print("|");
}else {
System.out.print(" ");
}
}
System.out.println();
}
}
//screen배열에 문자가 들어갈 위치를 찾아 1을 대입해준다
static private byte[][] spray(byte[][] screen, int width, int height, int curRow, int curColumn, int number){
//첫 행일 경우 '-'문자를 넣는다.
if(curRow == 0) {
//맨 윗줄에 '-'문자가 들어가는 숫자의 경우 배열의 해당 인덱스 1 대입
if(number != 1 && number != 4) {
for(int i = curColumn; i < curColumn+width; i++)
if(i != curColumn && i != curColumn+width-1)
screen[curRow][i] = 1;
}
}
//가운데 행일 경우 '-'를 넣는다
if(curRow == height/2) {
//맨 윗줄에 '-'문자가 들어가는 숫자의 경우 배열의 해당 인덱스 1 대입
if(number != 1 && number != 7 && number != 0) {
for(int i = curColumn; i < curColumn+width; i++)
if(i != curColumn && i != curColumn+width-1)
screen[curRow][i] = 1;
}
}
//끝 행일 경우 '-'를 넣는다
if(curRow == height-1) {
//맨 윗줄에 '-'문자가 들어가는 숫자의 경우 배열의 해당 인덱스 1 대입
if(number != 1 && number != 7 && number != 4 && number != 9) {
for(int i = curColumn; i < curColumn+width; i++)
if(i != curColumn && i != curColumn+width-1)
screen[curRow][i] = 1;
}
}
//가운데 행을 기준으로 위쪽행일때,
if(curRow < height/2 && curRow != 0) {
//왼쪽사이드에 '|'가 있는 숫자들은 screen배열에 1대입
if(number != 1 && number != 2 && number != 3 && number != 7)
screen[curRow][curColumn] = 1;
//오른쪽사이드에 '|'가 있는 숫자들은 screen배열에 1대입
if(number != 5 && number != 6)
screen[curRow][curColumn+size+1] = 1;
}
//가운데 행을 기준으로 아래쪽행일때,
if(curRow > height/2 && curRow != height-1) {
//왼쪽사이드에 '|'가 있는 숫자들은 screen배열에 1 대입
if(number != 1 && number != 3 && number != 4 && number != 5 && number != 7 && number != 9)
screen[curRow][curColumn] = 1;
//오른쪽사이드에 '|'가 있는 숫자들은 screen배열에 1 대입
if(number != 2)
screen[curRow][curColumn+size+1] = 1;
}
return screen;
}
static private boolean getInputData() {
Scanner scan = new Scanner(System.in);
do {
size = scan.nextInt();
number = scan.nextInt();
}while((size < 0 || size > 9)
|| (number < 0 || number > 99999999));
if(size == 0 && number == 0)
return false;
else
return true;
}
}
좋은 로직이 생각나지 않아 노가다마냥 처리해버렸습니다...ㅠㅠ 로직은 대충 아래와같아요.
문제에 주어진 각 숫자가 차지하는 가로크기s+2 / 세로크기2*s+3을 이용하여 전체화면을 나타낼 byte형 2차원배열(screen)을 생성
screen에서 첫번째,가운데,끝 행은 '-'문자가 들어간다. 이 때, 한 숫자가 차지하는 행의 길이에서 맨처음,끝을 제외한 나머지는 모두 '-'로 채워주는 것을 볼 수 있다. screen배열에서 이 부분에 1을 대입해준다 ^^
'|'문자가 들어갈 부분을 크게 2군데로 나눴습니다. 가운데 행 기준으로 위와 아래. 그리고 윗행에서 좌측벽에 '|'가 붙는경우, 우측벽에 '|'가 붙는경우 두가지로 나눴구요. 모든 숫자를 다 들여다보고 구분했습니다. 이놈이 위쪽구역 왼쪽벽에 '|'가있는지 오른쪽에있는지.... if문으로 다 나눠서 조건처리해줬습니다. 예를들어 왼쪽벽에 붙은 경우는 for문돌려서 해당 index부터 밑에 행으로 내려가면서 가운데행에 도달하기 전까지 모두 1을 대입해줬습니다.
3번까지의 과정이 끝난 후 출력할 때, screen배열에서 처음,가운데,끝행에 1이 들어가있는 요소는 모두 '-'을 출력하고, 나머지행에 1이 들어가있는 요소가 탐색되면 '|'출력하고, 이 외의 나머지는 ' ' 공백을 출력하였습니다.
결과는 문제에 나와있는 것과 같이 나옵니다.
주석이 부실한 점은 죄송합니다..ㅠㅠ
#3. LCD Display
#0. 숫자모양
D1 = [[' ',' ',' '],[' ',' ','|'],[' ',' ',' '],[' ',' ','|'],[' ',' ',' ']]
D2 = [[' ','-',' '],[' ',' ','|'],[' ','-',' '],['|',' ',' '],[' ','-',' ']]
D3 = [[' ','-',' '],[' ',' ','|'],[' ','-',' '],[' ',' ','|'],[' ','-',' ']]
D4 = [[' ',' ',' '],['|',' ','|'],[' ','-',' '],[' ',' ','|'],[' ',' ',' ']]
D5 = [[' ','-',' '],['|',' ',' '],[' ','-',' '],[' ',' ','|'],[' ','-',' ']]
D6 = [[' ','-',' '],['|',' ',' '],[' ','-',' '],['|',' ','|'],[' ','-',' ']]
D7 = [[' ','-',' '],[' ',' ','|'],[' ',' ',' '],[' ',' ','|'],[' ',' ',' ']]
D8 = [[' ','-',' '],['|',' ','|'],[' ','-',' '],['|',' ','|'],[' ','-',' ']]
D9 = [[' ','-',' '],['|',' ','|'],[' ','-',' '],[' ',' ','|'],[' ','-',' ']]
D0 = [[' ','-',' '],['|',' ','|'],[' ',' ',' '],['|',' ','|'],[' ','-',' ']]
#1. 값 입력
nums = input()
space = nums.find(' ')
size = int(nums[0:space])
display = nums[space+1:]
#2. 숫자 나열하기
for j in range(2*size + 3):
if j == 0:
j = 0
elif 0<j< (2*size+2)/2:
j = 1
elif j == (2*size+2)/2:
j = 2
elif (2*size+2)/2 < j < 2*size +2:
j = 3
else:
j = 4
for k in range(len(display)):
for i in range(size + 2):
if i==0:
i = 0
elif i == size+2 -1:
i = 2
else:
i = 1
eval("print(D{}[{}][{}],end='')".format(display[k],j,i))
print()
C#
별 생각 없는 코드
using static System.Console;
class SevenSegmentNumber
{
private int[][] segnums = new int[10][]
{
new int[] {1, 1, 1, 0, 1, 1, 1}, // 0
new int[] {0, 0, 1, 0, 0, 1, 0}, // 1
new int[] {1, 0, 1, 1, 1, 0, 1}, // 2
new int[] {1, 0, 1, 1, 0, 1, 1}, // 3
new int[] {0, 1, 1, 1, 0, 1, 0}, // 4
new int[] {1, 1, 0, 1, 0, 1, 1}, // 5
new int[] {1, 1, 0, 1, 1, 1, 1}, // 6
new int[] {1, 0, 1, 0, 0, 1, 0}, // 7
new int[] {1, 1, 1, 1, 1, 1, 1}, // 8
new int[] {1, 1, 1, 1, 0, 1, 1} // 9
};
private char[] segchars = new char[7] { '-', '|', '|', '-', '|', '|', '-' };
public int n { get; set; }
public char ToChar(int seg) => segnums[n][seg] == 1 ? segchars[seg] : ' ';
public SevenSegmentNumber(int n)
{
this.n = n;
}
}
class Display
{
private char[,] disp;
private int S, H, W, L;
public Display(int scale, int cnt)
{
S = scale;
H = S * 2 + 3;
W = S + 2;
L = (W + 1) * cnt - 1;
disp = new char[H, L];
}
private void WriteNum(int n, int Y)
{
SevenSegmentNumber N = new SevenSegmentNumber(n);
for (int i = 0; i < S; i++)
{
disp[0, Y + i + 1] = N.ToChar(0);
disp[i + 1, Y] = N.ToChar(1);
disp[i + 1, Y + W - 1] = N.ToChar(2);
disp[S + 1,Y + i + 1] = N.ToChar(3);
disp[S + 2 + i,Y] = N.ToChar(4);
disp[S + 2 + i,Y + W - 1] = N.ToChar(5);
disp[2 * S + 2,Y + i + 1] = N.ToChar(6);
}
}
public void Set(string numbers)
{
int offset = 0;
foreach (char n in numbers)
{
WriteNum(int.Parse(n.ToString()), offset);
offset += W + 1;
}
}
public void Print()
{
for (int i = 0; i < H; i++)
{
for (int j = 0; j < L; j++)
{
Write(disp[i, j]);
}
WriteLine();
}
WriteLine();
}
}
class SevenSegment
{
static void Main(string[] args)
{
int scale = 1;
while (scale > 0)
{
string[] inp = ReadLine().Split();
scale = int.Parse(inp[0]);
string numbers = inp[1];
Display disp = new Display(scale, numbers.Length);
disp.Set(numbers);
disp.Print();
}
}
}
def Display_LCD(Line):
Size = int(Line.split()[0])
Number = Line.split()[1]
def Print_Num(Size, n):
num = [[1,3,0,3,1],
[0,2,0,2,0],
[1,2,1,1,1],
[1,2,1,2,1],
[0,3,1,2,0],
[1,1,1,2,1],
[1,1,1,3,1],
[1,2,0,2,0],
[1,3,1,3,1],
[1,3,1,2,1]]
for i in range(5):
if(i%2==0):
Line = ""
for j in range(len(n)):
Line+=" "
for k in range(Size):
if(num[int(n[j])][i] == 1): Line+="-"
else: Line+=" "
Line+=" "
print(Line)
else:
for j in range(Size):
Line=""
for k in range(len(n)):
if(num[int(n[k])][i] == 0):
for l in range(Size+2): Line+=" "
elif(num[int(n[k])][i] == 1):
Line+="|"
for l in range(Size+1): Line+=" "
elif(num[int(n[k])][i] == 2):
for l in range(Size+1): Line+=" "
Line+="|"
elif(num[int(n[k])][i] == 3):
Line+="|"
for l in range(Size): Line+=" "
Line+="|"
Line+=" "
print(Line)
while True:
Display_LCD(input())
정말 기초적인 실력이나마 풀이해봅니다. 버전은 파이썬 3입니다.
num 이라는 이차원 리스트는 0~9까지의 숫자를 디지털숫자 형식으로 표현해 놓은 것입니다.
각 디지털 숫자의 짝수인덱스는 맨위와 중간, 맨아래를 나타내므로 수평선이 있는지 여부를 0과 1로 나타내었습니다.
홀수인덱스는 그 외의 수직선이 들어갈 위치를 나타내므로 수직선 없음, 왼쪽 한개, 오른쪽 한개, 양쪽 수직선의 여부를 각각 0,1,2,3 으로 나타내었습니다.
출력할 때는 이전에 말씀드렸던 짝수 인덱스와 홀수 인덱스일 상황으로 나누어
짝수일때는 미리 입력했던 사이즈 만큼 수평선을 출력하는 상황을 받은 숫자의 길이만큼에 맞춰 출력하도록 하였고
홀수일때는 숫자의 길이만큼에 맞춰 수평선과 공백을 적절히 입력한 후 사이즈 만큼 반복하는 방식으로 작동합니다.
# python 3.6
def lcd(n, scale):
"""[0...9] LCD 포맷(fmt) 기준, 숫자 n을 scale에 맞추어 문자열 반환"""
fmt = ["-|| ||-", " | | ", "- |-| -", "- |- |-",
" ||- | ", "-| - |-", "-| -||-", "- | | ", "-||-||-", "-||- |-"]
rst = " " + fmt[n][0] * scale + " \n" + \
(fmt[n][1] + " " * scale + fmt[n][2] + "\n") * scale + \
" " + fmt[n][3] * scale + " \n" + \
(fmt[n][4] + " " * scale + fmt[n][5] + "\n") * scale + \
" " + fmt[n][6] * scale + " "
return rst
string = ""
while True:
get = input().split()
chkL = get[0]
chkR = get[1]
if chkL == "0" and chkR == "0": # 0 0 입력시 누적된 문자열 반환 후 종료
print(string)
break
scale = int(chkL)
# 입력 숫자에 해당하는 문자열을 뽑은 후 행별 출력을 위해 zip
lst = zip(*[lcd(num, scale).split("\n") for num in list(map(int, chkR))])
# 행별 문자열 누적
for i in lst:
string += " ".join(i) + "\n"
string += "\n"
def make_list_num(n):
ni_list = list(str(n))
n_list = []
for i in ni_list:
n_list.append(int(i))
return n_list
def map_size(a, n):
map_row = []
map_col = []
row = 2 * a + 3
col = (a + 2) * len(make_list_num(n)) + (len(make_list_num(n)) - 1)
for row_i in range(row):
map_col = []
for col_i in range(col):
map_col.append(" ")
map_row.append(map_col)
return map_row
def onoff(a, n):
map_squr = map_size(a, n)
n_list = make_list_num(n)
t = len(n_list)
count = 0
for k in n_list:
if count < t:
if k == 0 or k ==2 or k ==3 or k == 5 or k == 6 or k == 7 or k == 8 or k == 9:
for line in range (1, a+1):
map_squr[0][line + (count * (a+2) + 1)] = "-"
if k == 0 or k == 4 or k == 5 or k == 6 or k == 7 or k == 8 or k == 9:
for line in range (1, a+1):
map_squr[line][0 + (count * (a+2) + 1)] = "|"
if k ==0 or k == 1 or k == 2 or k == 3 or k ==4 or k == 7 or k == 8 or k == 9:
for line in range (1, a+1):
map_squr[line][a+1 + (count * (a+2) + 1)] = "|"
if k == 2 or k == 3 or k == 4 or k == 5 or k == 6 or k == 8 or k == 9:
for line in range (1, a+1):
map_squr[a+1][line + (count * (a+2) + 1)] = "-"
if k == 0 or k == 2 or k == 6 or k == 8:
for line in range (a+2, 2*a+2):
map_squr[line][0 + (count * (a+2) + 1)] = "|"
if k == 0 or k == 1 or k == 3 or k == 4 or k == 5 or k == 6 or k == 7 or k == 8 or k == 9:
for line in range (a+2, 2*a+2):
map_squr[line][a+1 + (count * (a+2) + 1)] = "|"
if k == 0 or k == 2 or k == 3 or k == 5 or k == 6 or k == 8 or k == 9:
for line in range (1, a+1):
map_squr[2*a+2][line + (count * (a+2) + 1)] = "-"
count = count + 1
return enter_line(map_squr)
def enter_line (list_ex):
lenth = len(list_ex)
full_str = ""
for i in list_ex:
full_str = full_str + "".join(i) + "\n"
return full_str
aii = input("input size: ")
nii = input("input number: ")
print (onoff(int(aii), int(nii)))
public class LcdDisplay { public static void main(String[] args) { lcd(3, "0123456789");
}
public static void lcd(int size, String digits) {
int nums[] = {0x77,0x24,0x5d,0x6d,0x2e,0x6b,0x7a,0x27,0x7f,0x2f};
for(int row=0; size>0 && row<size*2+3; row++)
for(int digit=0; digit<digits.length(); digit++){
int n = digits.charAt(digit) - '0';
for(int col=0; col<size+2; col++)
if(row%(size+1)==0 && col%(size+1)!=0 && (nums[n]&(1<<(row/(size+1)*3)))!=0)
System.out.print("-");
else if(row%(size+1)!=0 && col%(size+1)==0
&& (nums[n]&(1<<((row/(size+1)*3+col/(size+1)+1))))!=0)
System.out.print("|");
else
System.out.print(" ");
System.out.print(digit==digits.length()-1 ? "\n" : " ");
}
}
}
파이썬 3.6
"""
아이디어>
1) 입력받은 데이터 값 s를 활용하여 모든 요소가 ' '(공백)문자인 [column][row*len(n)] 크기의 배열을 생성하고
2) n의 각 숫자들을 표기하기 위한 값('-','|')을 각 첫 번째 숫자부터 순차적으로 위의 배열에 대입한다.
3) 모든 숫자 표기 값들을 대입한 후 각 행 배열의 row번째마다 ' '을 len(n)번 추가한 후 결과를 출력한다.
"""
data_list = []
def inputdata(data_list):
data = []
s = input("s = ")
if 0 <= int(s) < 10: data.append(s)
else:
print("범위 안의 숫자를 입력해주세요")
return
n = input("n = ")
if 0 <= int(n) <= 99999999:data.append(n)
else:
print("범위 안의 숫자를 입력해주세요")
return
if s == '0' and n == '0':
return
else:
data_list.append(data)
inputdata(data_list)
def lcddisplay(data):
print(data[0],data[1])
s,n = data[0],data[1]
column,row = 2*int(s)+3, int(s)+2
lcd_arr = []
for h in range(column):
lcd_arr.append([' ' for i in range(row*len(n))])
for g,value in enumerate(n):
if value == '1':
for q in range(column):
if q == 1 or q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if value == '2':
for q in range(column):
if q == 0 or q == int(column/2) or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-row] = '|'
if value == '3':
for q in range(column):
if q == 0 or q == int(column/2) or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1 or q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if value == '4':
for q in range(column):
if q == int(column/2):
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
lcd_arr[q+t][(row*(g+1))-row] = '|'
if q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if value == '5':
for q in range(column):
if q == 0 or q == int(column/2) or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-row] = '|'
if q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if value == '6':
for q in range(column):
if q == 0 or q == int(column/2) or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-row] = '|'
if q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
lcd_arr[q+t][(row*(g+1))-row] = '|'
if value == '7':
for q in range(column):
if q == 0:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1 or q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if value == '8':
for q in range(column):
if q == 0 or q == int(column/2) or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1 or q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
lcd_arr[q+t][(row*(g+1))-row] = '|'
if value == '9':
for q in range(column):
if q == 0 or q == int(column/2) or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
lcd_arr[q+t][(row*(g+1))-row] = '|'
if q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
if value == '0':
for q in range(column):
if q == 0 or q == column-1:
for t in range(int(s)):
lcd_arr[q][(row*g+1)+t] = '-'
if q == 1 or q == row:
for t in range(int(s)):
lcd_arr[q+t][(row*(g+1))-1] = '|'
lcd_arr[q+t][(row*(g+1))-row] = '|'
for arr in lcd_arr:
x = 0
for k in range(len(n)):
arr.insert(row*k+x,' ')
x += 1
print(''.join(arr))
def main(data_list):
for data in data_list: lcddisplay(data)
if __name__ == "__main__":
inputdata(data_list)
print("\n")
main(data_list)
*결과값
size = 2
number = 12345
size = 3
number = 67890
size = 0
number = 0
2 12345
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
3 67890
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
def printnum(list,size,string):
for i in range(2*size+3):
for j in range((size+3)*len(str(string))-1):
print(list[i][j],end='')
print('')
def one(list,r,size):
for i in range(2*size+3):
if i==0 or i==(2*size+3)//2 or i==2*size+2: continue
else:
list[i][r+size+1]='|'
def two(list,r,size):
temp=r
limit=r+size+1
for i in range(2*size+3):
if i==0 or i==(2*size+3)//2 or i==2*size+2:
while temp!=limit+1:
if temp==r or temp==limit: temp+=1
else:
list[i][temp]='-'
temp+=1
elif i>0 and i<(2*size+3)//2:
while temp!=limit+1:
if temp==limit:
list[i][temp]='|'
temp+=1
else: temp+=1
else:
while temp!=limit+1:
if temp==r:
list[i][temp]='|'
temp+=1
else: temp+=1
temp=r
while True:
info=list(map(int,input().split()))
if info[0]==0: break
num=[[' ']*((info[0]+3)*len(str(info[1]))-1) for i in range(2*info[0]+3)]
row,col=0,0
for i in str(info[1]):
if i=='1':
one(num,row,info[0])
row+=(3+info[0])
elif i=='2':
two(num,row,info[0])
row+=(3+info[0])
elif i=='3': pass
elif i=='4': pass
elif i=='5': pass
elif i=='6': pass
elif i=='7': pass
elif i=='8': pass
elif i=='9': pass
printnum(num,info[0],info[1])
1과 2만 구현하였습니다..많이 버겁네요! 짜고 바로 올리는거라 많이 더럽습니다!
#-------------for abstracting function----------------------
def abstract(n,l):
a = []
temp = n
for b in range(1,l+1):
c = temp%10
a.append(c)
temp = temp/10
a.reverse()
return a
#--------------for printing function-------------------------
def printing(s,src):
print(src)
bigmatrix = []
for ty in src:
matrix = [[' ']*(s+2) for i in range(2*s+3)]
if ty==0:
for temp in range(1,s+1):
matrix[0][temp] = '-'
matrix[2*s+2][temp] = '-'
for temp in range(1,s+1):
matrix[temp][0] = '|'
matrix[temp][s+1] = '|'
for temp in range(2*s+1,(2*s+1)-s,-1):
matrix[temp][0] = '|'
matrix[temp][s+1] = '|'
bigmatrix.append(matrix)
for z in range(2*s+3):
l = matrix[z]
print "".join(l)
enter = [] #I save the all input distinguished by line
#---------------enter the input-----------------------------
while True:
a, b = raw_input().split()
c = len(b) #this is for n's length
a = int(a)
b = int(b)
if a==0 and b ==0:
break
d = [a,b,c]
enter.append(d)
print(entfor i in enter:
s = i[0]
n = i[1]
l = i[2]
src = abstract(n,l)
print(src)
printing(s,srcer)
R로 풀었습니다. 코드가 엄청 길어지네요.
func <- function(x,y){
if(y %% 1 != 0 | x %% 1 != 0){
warning("정수값을 입력하세요.")
}
if(y < 0 | y >99999999){
warning("n의 범위는 0 <= n <= 99,999,999입니다.")
}else if(x < 1 | x >= 10){
warning("s의 범위는 1 <= s < 10입니다.")
}
a <- as.character(y)
b <- unlist(str_split(a,""))
c <- length(b)
m2 <- function(x){
m1 <- " "
for(i in 1:x){
m1 <- paste0(m1," ")
}
m1 <- paste0(m1," ")
return(m1)
}
m3 <- function(x){
m1 <- " "
for(i in 1:x){
m1 <- paste0(m1,"-")
}
m1 <- paste0(m1," ")
return(m1)
}
m4 <- function(x){
m1 <- "|"
for(i in 1:x){
m1 <- paste0(m1," ")
}
m1 <- paste0(m1," ")
return(m1)
}
m5 <- function(x){
m1 <- " "
for(i in 1:x){
m1 <- paste0(m1," ")
}
m1 <- paste0(m1,"|")
return(m1)
}
m6 <- function(x){
m1 <- "|"
for(i in 1:x){
m1 <- paste0(m1," ")
}
m1 <- paste0(m1,"|")
return(m1)
}
f1 <- function(x){
m1 <- NULL
for(i in 1:c){
if(b[i] == '1' | b[i] == '4'){
m1 <- paste0(m1, m2(x), " ")
}else{
m1 <- paste0(m1, m3(x), " ")
}
}
return(m1)
}
f2 <- function(x){
m1 <- NULL
for (i in 1:c){
if(b[i] == '5' | b[i] == '6'){
m1 <- paste0(m1, m4(x), " ")
}else if(b[i] == '1' | b[i] == '2' | b[i] == '3' | b[i] == '7'){
m1 <- paste0(m1, m5(x), " ")
}else{
m1 <- paste0(m1, m6(x), " ")
}
}
return(m1)
}
f3 <- function(x){
m1 <- NULL
for(i in 1:c){
if(b[i] == '1' | b[i] == '7'| b[i] == '0'){
m1 <- paste0(m1, m2(x), " ")
}else{
m1 <- paste0(m1, m3(x), " ")
}
}
return(m1)
}
f4 <- function(x){
m1 <- NULL
for (i in 1:c){
if(b[i] == '2'){
m1 <- paste0(m1, m4(x), " ")
}else if(b[i] == '1' | b[i] == '3' | b[i] == '4' | b[i] == '5'| b[i] == '7' | b[i] == '9'){
m1 <- paste0(m1, m5(x), " ")
}else{
m1 <- paste0(m1, m6(x), " ")
}
}
return(m1)
}
f5 <- function(x){
m1 <- NULL
for(i in 1:c){
if(b[i] == '1' | b[i] == '4' | b[i] == '7'){
m1 <- paste0(m1, m2(x), " ")
}else{
m1 <- paste0(m1, m3(x), " ")
}
}
return(m1)
}
# 글자출력
print(f1(x))
for(j in 1:x){
print(f2(x))
}
print(f3(x))
for(j in 1:x){
print(f4(x))
}
print(f5(x))
}
func(1,12345)
func(2,67890
def display(n):
return {1 : [' '*(n+2), ' '*(n+1)+'|', ' '*(n+2), ' '*(n+1)+'|', ' '*(n+2)],
2 : [' '+'-'*n+' ', ' '*(n+1)+'|', ' '+'-'*n+' ', '|'+' '*(n+1), ' '+'-'*n+' '],
3 : [' '+'-'*n+' ', ' '*(n+1)+'|', ' '+'-'*n+' ', ' '*(n+1)+'|', ' '+'-'*n+' '],
4 : [' '*(n+2), '|'+' '*n+'|', ' '+'-'*n+' ', ' '*(n+1)+'|', ' '*(n+2)],
5 : [' '+'-'*n+' ', '|'+' '*(n+1), ' '+'-'*n+' ', ' '*(n+1)+'|', ' '+'-'*n+' '],
6 : [' '+'-'*n+' ', '|'+' '*(n+1), ' '+'-'*n+' ', '|'+' '*n+'|', ' '+'-'*n+' '],
7 : [' '+'-'*n+' ', ' '*(n+1)+'|', ' '*(n+2), ' '*(n+1)+'|', ' '*(n+2)],
8 : [' '+'-'*n+' ', '|'+' '*n+'|', ' '+'-'*n+' ', '|'+' '*n+'|', ' '+'-'*n+' '],
9 : [' '+'-'*n+' ', '|'+' '*n+'|', ' '+'-'*n+' ', ' '*(n+1)+'|', ' '+'-'*n+' '],
0 : [' '+'-'*n+' ', '|'+' '*n+'|', ' '*(n+2), '|'+' '*n+'|', ' '+'-'*n+' ']}
def lcd(n, a):
l = ''
for i in range(len(a)):
l += display(n).get(int(a[i]))[0]+' '
l += '\n'
for j in range(n):
for i in range(len(a)):
l += display(n).get(int(a[i]))[1] + ' '
l += '\n'
for i in range(len(a)):
l += display(n).get(int(a[i]))[2] + ' '
l += '\n'
for j in range(n):
for i in range(len(a)):
l += display(n).get(int(a[i]))[3] + ' '
l += '\n'
for i in range(len(a)):
l += display(n).get(int(a[i]))[4] + ' '
return l
while 1:
n = input().split(' ')
if n == ['0', '0']:
break
else:
print(lcd(int(n[0]), n[1]))
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
public class LCDDisplay {
public static char[][][] printArray(char[][][] array, int[][] numberArray){
for(int k=0; k< numberArray.length; k++){
while(numberArray[k][1] != 0){
int d = numberArray[k][1] % 10;
numberArray[k][1] /= 10;
switch(d){
case 1 :
for(int i = 1; i< array[k][0].length-1; i++){
array[k][0][i] = '-';
}
break;
case 2 :
for(int i = 1; i < array[k].length/2; i++){
array[k][i][0] = '|';
}
break;
case 3 :
for(int i = 1; i < array[k].length/2; i++){
array[k][i][array[k][0].length-1] = '|';
}
break;
case 4 :
for(int i = 1; i< array[k][0].length-1; i++){
array[k][array[k].length/2][i] = '-';
}
break;
case 5 :
for(int i = array[k].length/2+1; i < array[k].length - 1; i++){
array[k][i][0] = '|';
}
break;
case 6 :
for(int i =array[k].length/2+1; i < array[k].length - 1; i++){
array[k][i][array[k][0].length-1] = '|';
}
break;
case 7 :
for(int i = 1; i< array[k][0].length-1; i++){
array[k][array[k].length-1][i] = '-';
}
break;
}
}
}
return array;
}
public static void execute(List testCase){
for(int i=0; i<testCase.size(); i++){
String inputNumber = (String) testCase.get(i);
StringTokenizer stn = new StringTokenizer(inputNumber, " ");
String sString = stn.nextToken();
String nString = stn.nextToken();
int s = Integer.parseInt(sString);
int n = Integer.parseInt(nString);
int[][] digitNumber = new int[(int)(Math.log10(n)+1)][2];
int num = n;
for(int a=0; a< digitNumber.length; a++){
if(num % 10 == 0){
digitNumber[a][1] = 123567;
}else if(num % 10 == 1){
digitNumber[a][1] = 36;
}else if(num % 10 == 2){
digitNumber[a][1] = 13457;
}else if(num % 10 == 3){
digitNumber[a][1] = 13467;
}else if(num % 10 == 4){
digitNumber[a][1] = 2346;
}else if(num % 10 == 5){
digitNumber[a][1] = 12467;
}else if(num % 10 == 6){
digitNumber[a][1] = 124567;
}else if(num % 10 == 7){
digitNumber[a][1] = 136;
}else if(num % 10 == 8){
digitNumber[a][1] = 1234567;
}else if(num % 10 == 9){
digitNumber[a][1] = 123467;
}
digitNumber[a][0] = num % 10;
num /= 10;
}
char[][][] display = new char[(int) (Math.log10(n)+1)][2*s+3][s+2]; //[표현글자수][행][열]
for(int k=0; k<display.length; k++){ // 빈공간에 전부 공간 넣기
for(int j=0; j<display[i].length; j++){
for(int m = 0; m<display[i][j].length; m++){
display[k][j][m] = ' ';
}
}
}
char[][][] test = printArray(display, digitNumber); //글자 생성
for(int b=0; b< 2*s+3; b++){
for(int a= (int) (Math.log10(n)); a >= 0 ; a--){
for(int c = 0; c< s+2; c++){
System.out.print(test[a][b][c]);
}
System.out.print(" ");
}
System.out.println();
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = sc = new Scanner(System.in);
List testCase = new ArrayList();
while(sc.hasNextLine()){
String input = sc.nextLine();
if(!input.equals("0 0")){
testCase.add(input);
}else{
break;
}
}
execute(testCase);
}
}
2 12345
3 67890
0 0
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
swift4.0으로 작성해보았습니다.
/*
각 번호 별 표시되는 위치
0 : 상단 -
1 : 상단 왼쪽 |
2 : 상단 오른쪽 |
3 : 중간 -
4 : 하단 왼쪽 |
5 : 하단 오른쪽 |
6 : 하단 -
*/
var table:[[Int]] = [
[2, 3, 5, 6, 7, 8, 9, 0], //0
[4, 5, 6, 7, 8, 9, 0], //1
[1, 2, 3, 4, 7, 8, 9, 0], //2
[2, 3, 4, 5, 6, 8, 9], //3
[2, 6, 8, 0], //4
[1, 3, 4, 5, 6, 7, 8, 9, 0], //5
[2, 3, 5, 6, 8, 9, 0] //6
]
while true {
let data = readLine()!.components(separatedBy: " ").map{Int($0)!}
let size = data[0]
let number = data[1]
if size == 0 && number == 0 {
break
}
let strNumbers = String(number)
var i = 0
for _ in 0..<5{
switch i {
case 0, 3, 6 :
var display = ""
for strNumber in strNumbers.enumerated() {
let number = Int(String(strNumber.element))!
var charY = ""
if table[i].contains(number) {
charY = "-"
} else {
charY = " "
}
let displayY = " " + Array(repeatElement(charY, count: size)).joined() + " "
display += displayY
}
print(display)
i += 1
default:
for _ in 0..<size {
var display = ""
for strNumber in strNumbers.enumerated() {
let number = Int(String(strNumber.element))!
var displayX = ""
if table[i].contains(number) && table[i+1].contains(number) {
displayX = "|" + Array(repeatElement(" ", count: size)).joined() + "|"
} else if table[i].contains(number) && table[i+1].contains(number) == false {
displayX = "|" + Array(repeatElement(" ", count: size + 1)).joined()
} else if table[i].contains(number) == false && table[i+1].contains(number) {
displayX = Array(repeatElement(" ", count: size + 1)).joined() + "|"
} else {
displayX = Array(repeatElement(" ", count: size + 2)).joined()
}
display += displayX
}
print(display)
}
i += 2
}
}
}
Swift입니다.
import Foundation
let fontTable = [["23567890"], // Top
["456890", "12347890"], // Upper left, right
["2345689"], // Middle
["2680", "134567890"], // Lower left, right
["2356890"]] // Bottom
let inputString = readLine()!
let inputArray = inputString.split(separator:",")
let count = Int(inputArray[0])!
let numberString = inputArray[1].trimmingCharacters(in: NSCharacterSet.whitespaces)
for fontIndex in 0...4 {
if fontIndex % 2 == 0 { // Top, Middle, Bottom
for number in numberString {
print(" ", terminator: "")
for _ in 1...count {
print(fontTable[fontIndex][0].contains(number) ? "-" : " ", terminator: "")
}
print(" ", terminator: "")
}
print("")
} else { // Upper, Lower
for _ in 1...count {
for number in numberString {
print(fontTable[fontIndex][0].contains(number) ? "|" : " ", terminator: "")
for _ in 1...count {
print(" ", terminator: "")
}
print(fontTable[fontIndex][1].contains(number) ? "|" : " ", terminator: "")
}
print("")
}
}
}
/* LCD Display */
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
var format map[int]string = map[int]string{
0: "pbnbp", 1: "nrnrn", 2: "prplp", 3: "prprp", 4: "nbprn",
5: "plprp", 6: "plpbp", 7: "prnrn", 8: "pbpbp", 9: "pbprp"}
func main() {
var (
inp1 int
inp2 string
scale []int
numstr []string
)
for {
fmt.Print("Input [s]cale & [n]umber (ex. '3 12345' or '0 0' to quit): ")
n, err := fmt.Scanf("%d %s\n", &inp1, &inp2)
if n != 2 || err != nil {
panic("Invalid input")
}
if inp1 == 0 && inp2 == "0" {
for idx, _ := range scale {
printNums(scale[idx], numstr[idx])
}
os.Exit(0)
}
scale = append(scale, inp1)
numstr = append(numstr, inp2)
}
}
// strgen generates string corrsponding [p]lain, [l]eft, [r]ight, [b]oth, [n]ull
func strgen(s string) string {
rst := ""
switch s {
case "p":
rst = " - "
case "l":
rst = "| "
case "r":
rst = " |"
case "b":
rst = "| |"
case "n":
rst = " "
}
return rst
}
// lcd returns scaled lcd string as slice
func lcd(num, scale int) []string {
var rst []string
for idx := 0; idx < len(format[num]); idx++ {
chk := strgen(format[num][idx : idx+1])
genstr := chk[0:1] + strings.Repeat(chk[1:2], scale) + chk[2:3]
if idx%2 == 0 {
rst = append(rst, genstr)
} else {
for i := 0; i < scale; i++ {
rst = append(rst, genstr)
}
}
}
return rst
}
// printNums display lcd numbers
func printNums(scale int, numstr string) {
// numstr := strconv.Itoa(nums)
rst := make([]string, scale*2+3)
for idx := 0; idx < len(numstr); idx++ {
num, _ := strconv.Atoi(numstr[idx : idx+1])
lcded := lcd(num, scale) // []string
for i := 0; i < len(rst); i++ {
rst[i] += (lcded[i] + " ")
}
}
for idx := 0; idx < len(rst); idx++ {
fmt.Println(rst[idx])
}
}
import numpy as np
s, n = input().split()
q = len(n)
s = int(s)
a = 3 + 2 * s
b = q * (s + 2)
a_list = np.zeros((a, b), dtype="U4")
def mat1(s, y, a_list):
for j in range(s):
a_list[0][j + y + 1] = '-'
return a_list
def mat2(s, y, a_list):
for j in range(s):
a_list[1 + j][y] = '|'
return a_list
def mat3(s, y, a_list):
for j in range(s):
a_list[1 + j][y + s + 1] = '|'
return a_list
def mat4(s, y, a_list):
for j in range(s):
a_list[1+s][1 + j + y] = '-'
return a_list
def mat5(s, y, a_list):
for j in range(s):
a_list[2 + s + j][y] = '|'
return a_list
def mat6(s, y, a_list):
for j in range(s):
a_list[2 + s + j][y + s + 1] = '|'
return a_list
def mat7(s, y, a_list):
for j in range(s):
a_list[2 + 2 * s][1 + j + y] = '-'
return a_list
def num(s, u, y, a_list):
u = int(u)
if u == 0:
mat1(s, y, a_list)
mat2(s, y, a_list)
mat3(s, y, a_list)
mat5(s, y, a_list)
mat6(s, y, a_list)
mat7(s, y, a_list)
elif u == 1:
mat3(s, y, a_list)
mat6(s, y, a_list)
elif u == 2:
mat1(s, y, a_list)
mat3(s, y, a_list)
mat4(s, y, a_list)
mat5(s, y, a_list)
mat7(s, y, a_list)
elif u == 3:
mat1(s, y, a_list)
mat3(s, y, a_list)
mat4(s, y, a_list)
mat6(s, y, a_list)
mat7(s, y, a_list)
elif u == 4:
mat2(s, y, a_list)
mat3(s, y, a_list)
mat4(s, y, a_list)
mat6(s, y, a_list)
elif u == 5:
mat1(s, y, a_list)
mat2(s, y, a_list)
mat4(s, y, a_list)
mat6(s, y, a_list)
mat7(s, y, a_list)
elif u == 6:
mat1(s, y, a_list)
mat2(s, y, a_list)
mat4(s, y, a_list)
mat5(s, y, a_list)
mat6(s, y, a_list)
mat7(s, y, a_list)
elif u == 7:
mat1(s, y, a_list)
mat3(s, y, a_list)
mat6(s, y, a_list)
elif u == 8:
mat1(s, y, a_list)
mat2(s, y, a_list)
mat3(s, y, a_list)
mat4(s, y, a_list)
mat5(s, y, a_list)
mat6(s, y, a_list)
mat7(s, y, a_list)
elif u == 9:
mat1(s, y, a_list)
mat2(s, y, a_list)
mat3(s, y, a_list)
mat4(s, y, a_list)
mat6(s, y, a_list)
mat7(s, y, a_list)
return a_list
for i in range(q):
y = (s+2) * i
a_list = num(s, n[i], y, a_list)
for i in range(a):
for j in range(b):
if a_list[i][j] == '':
print(' ', end = '')
else:
print(a_list[i][j], end = '')
print('\n')
// java
public class LcdDisplay {
public static void main(String[] args) {
lcd(3, "0123456789");
}
public static void lcd(int size, String digits) {
int nums[] = {0x77,0x24,0x5d,0x6d,0x2e,0x6b,0x7a,0x27,0x7f,0x2f};
for(int row=0; size>0 && row<size*2+3; row++)
for(int digit=0; digit<digits.length(); digit++){
int n = digits.charAt(digit) - '0';
for(int col=0; col<size+2; col++)
if(row%(size+1)==0 && col%(size+1)!=0 && (nums[n]&(1<<(row/(size+1)*3)))!=0)
System.out.print("-");
else if(row%(size+1)!=0 && col%(size+1)==0
&& (nums[n]&(1<<((row/(size+1)*3+col/(size+1)+1))))!=0)
System.out.print("|");
else
System.out.print(" ");
System.out.print(digit==digits.length()-1 ? "\n" : " ");
}
}
}
아무것도 입력을 안하고 엔터를 치면 프로그램이 실행되도록 짜봤습니다. 10줄 안으로 끝내신 분들도 많네요. 배워갑니다 ~~
def my_func(s, a):
if s==0 and a==0:
return
a = str(a)
for ch in a:
if ch not in ['1', '4']:
print(' ' + '-'*s +' ', end=' ')
else:
print(' '*(s+2), end=' ')
print('\n')
#위
for _ in range(s):
for ch in a:
t=''
if ch in ['4','5','6','8','9','0']: # 왼쪽작대기 조건
t+='|'
else:
t +=' '
t = t+ ' '*s
if ch not in ['5', '6']: # 오른쪽작대기 조건
t += '|'
else:
t += ' '
print(t, end=' ')
print('\n')
for ch in a:
if ch not in ['1', '7', '0']:
print(' ' + '-'*s +' ', end=' ')
else:
print(' '*(s+2), end=' ')
print('\n')
#아래javascript:insert_code();
for _ in range(s):
for ch in a:
t=''
if ch in ['2','6','8','0']:# 왼쪽작대기 조건
t+='|'
else:
t +=' '
t = t+ ' '*s
if ch not in ['2']: # 오른쪽작대기 조건
t += '|'
else:
t += ' '
print(t, end=' ')
print('\n')
for ch in a:
if ch not in ['1', '4', '7']:
print(' ' + '-'*s +' ', end=' ')
else:
print(' '*(s+2), end=' ')
print('\n')
def solution(tmp):
for t in tmp:
s,a = t.split(' ')
my_func(int(s), a)
print('\n')
a =[]
while True:
input_num = input()
if input_num=='': break
a.append(input_num)
solution(a)
while True :
mylist = input("please insert the magnitude and desired number: ").split(" ")
if mylist == ['0','0']:
print("Bye")
break
size = int(mylist[0])
number = mylist[1]
# step 1 : upper -
for num in number:
print(" ",end='')
if num == '1' or num == '4':
print(" "* size, end='')
else : print("-"*size, end='')
print(" ", end=' ')
print(" ")
# step 2 : upper |
for i in range(size):
for num in number:
if num == '5' or num == '6' :
print("|"+ (" " * (size+1)), end=' ')
elif num == '0' or num =='4' or num == '8' or num == '9':
print("|" + (" " * (size))+ "|", end=' ')
else: print((" " * (size+1))+ "|", end=' ')
print(" ")
# step 3 : middle -
for num in number:
print(" ",end='')
if num == '0'or num=='1'or num=='7':
print(" "*size, end=' ')
else : print("-"*size,end=' ')
print(" ",end='')
print(" ")
# step 4 : lower |
for i in range(size):
for num in number :
if num =='2':
print("|" + (" "* (size +1)),end=' ')
elif num =='0' or num == '6' or num=='8':
print("|"+(" "* size)+ "|", end=' ')
else:
print((" "* (size +1))+"|",end=' ')
print(" ")
# step 5 : lower -
for num in number:
print(" ",end='')
if num == '1' or num == '4' or num == '7':
print(" "* size, end=' ')
else : print("-"*size, end=' ')
print(" ", end='')
print(" ")
def p314():
# top up-l,r mid dn-l,r bottom
d = {0:["-", "||", " ", "||", "-"],
1:[" ", " |", " ", " |", " "],
2:["-", " |", "-", "| ", "-"],
3:["-", " |", "-", " |", "-"],
4:[" ", "||", "-", " |", " "],
5:["-", "| ", "-", " |", "-"],
6:["-", "| ", "-", "||", "-"],
7:["-", " |", " ", " |", " "],
8:["-", "||", "-", "||", "-"],
9:["-", " |", "-", " |", "-"]}
s, n = input().split()
while s != "0" and n != "0":
size = int(s)
nums = [int(x) for x in n]
for r in range(2*size+3):
line = ""
for n in nums:
if r == 0:
line += (" " + d[n][0]*size + " " )
elif r < size+1:
line += (d[n][1][0] + " "*size + d[n][1][1] )
elif r == size+1:
line += (" " + d[n][2]*size + " " )
elif r < 2*size+2:
line += (d[n][3][0] + " "*size + d[n][3][1] )
else:
line += (" " + d[n][4]*size + " " )
line += " "
print(line)
s, n = input().split()
if __name__ == "__main__":
p314()
package h_LCD_display_num; import java.util.Scanner; public class DisplayNum { public static void main(String[] args) { int N=20;//Input Limit String[] hori={"02356789","2345689","2356890"}; String[][] verti={{"045689","01234789"},{"0268","013456789"}};
Scanner in=new Scanner(System.in);
int[] s=new int[N]; String[] n=new String[N];
int L=-1,l,c,i,j,t,v;
do{ s[++L]=in.nextInt(); n[L]=in.next(); }while( s[L]!=0 && n[L]!="0" ); //입력받음
for(l=0;l<L;l++){ //입력한 줄 한줄씩
for(t=0;t<3;t++){
for(c=0;c<n[l].length();c++){ System.out.print(" "); //가로선 ~ c:한 숫자씩
for(i=0;i<s[l];i++) System.out.print((hori[t].contains(n[l].charAt(c)+""))?"-":" ");
System.out.print(" ");
}System.out.println();
if(t<2) for(j=0;j<s[l];j++){ //세로선
for(c=0;c<n[l].length();c++){
for(v=0;v<2;v++){
System.out.print((verti[t][v].contains(n[l].charAt(c)+""))?"|":" ");
if(v==0) for(i=0;i<s[l];i++) System.out.print(" ");
else System.out.print(" ");
}
}System.out.println();
}
}System.out.println();
}
}}
"""
author: Kenny Jeon
date: 06/05/2018
"""
def func(s, nums):
# top, up-l,r mid dn-l,r bottom
d = {0: ["-", "||", " ", "||", "-"],
1: [" ", " |", " ", " |", " "],
2: ["-", " |", "-", "| ", "-"],
3: ["-", " |", "-", " |", "-"],
4: [" ", "||", "-", " |", " "],
5: ["-", "| ", "-", " |", "-"],
6: ["-", "| ", "-", "||", "-"],
7: ["-", " |", " ", " |", " "],
8: ["-", "||", "-", "||", "-"],
9: ["-", "||", "-", " |", "-"]}
for r in range(2 * s + 3):
line = ""
for i in nums:
if r == 0:
line += (" " + d[i][0] * s + " ")
# draw first row
elif r < s + 1:
line += (d[i][1][0] + " " * s + d[i][1][1])
# draw vertical line until r[s]
elif r == s + 1:
line += (" " + d[i][2] * s + " ")
# draw d[i][2]
elif r < 2 * s + 2:
line += (d[i][3][0] + " " * s + d[i][3][1])
# draw vertical line until r[s+1]
else:
line += (" " + d[i][4] * s + " ")
# draw last row
line += " "
# insert space
print(line)
if __name__ == "__main__":
while True:
li = input("insert s and n: ").split()
s = int(li[0])
n = li[1]
nums = [int(val) for idx, val in enumerate(n)]
# assign input variables
if s == 0 and int(n) == 0:
print("bye")
break
elif s < 1 or s >= 10 or int(n) < 0 or int(n) > 99999999:
print("out of bound")
# define break case
else:
func(s, nums)
Python
table = [["23567890"],#-
["456890", "12347890"],#|
["2345689"],#-
["2680", "134567890"],#|
["2356890"]]#-
h, p, e = "-", "|", " "
while True:
s, n = map(int, input().split(' '))
#n = 12345
#s = 2
if n == 0 and s == 0:
break
for r in range(len(table)):
t = table[r]
if len(t) == 1:
for d in str(n):
a = h*s if d in t[0] else e*s
print(" {} ".format(a), end=" ")
print()
else:
for k in range(s):
for d in str(n):
for b in range(len(t)):
if b == 0:
a = p+" "*s if d in t[b] else e+" "*s
else:
a = p if d in t[b] else e
print(a, end="")
print(" ",end="")
print()
#break
import sys
import numpy as np
display_table = [[1,1,1,0,1,1,1] # 0
,[0,0,1,0,0,1,0] # 1
,[1,0,1,1,1,0,1] # 2
,[1,0,1,1,0,1,1] # 3
,[0,1,1,1,0,1,0] # 4
,[1,1,0,1,0,1,1] # 5
,[1,1,0,1,1,1,1] # 6
,[1,0,1,0,0,1,0] # 7
,[1,1,1,1,1,1,1] # 8
,[1,1,1,1,0,1,1]] # 9
def printMatrix( m ):
for i in range(m.shape[0]):
for j in range(m.shape[1]):
if m[i,j] == 1:
print("|", end='')
elif m[i,j] == 2:
print("-", end='')
else:
print(" ", end='')
print("\n", end='')
def numberToMatrix(number, row, col):
m = np.zeros((row,col))
l = display_table[number]
if l[0] == 1:
for i in range(s):
m[0,i+1] = 2
if l[1] == 1:
for i in range(s):
m[i+1,0] = 1
if l[2] == 1:
for i in range(s):
m[i+1,s+1] = 1
if l[3] == 1:
for i in range(s):
m[s+1,i+1] = 2
if l[4] == 1:
for i in range(s):
m[s+2+i,0] = 1
if l[5] == 1:
for i in range(s):
m[s+2+i,s+1] = 1
if l[6] == 1:
for i in range(s):
m[2*s+2,i+1] = 2
return m
if __name__ == "__main__":
s = int(sys.argv[1])
row = 2 * s + 3
col = s + 2
sum_m = np.zeros((row,0))
zero_m = np.zeros((row,1))
for i in range(len(sys.argv[2])):
cur_m = numberToMatrix(int(sys.argv[2][i]), row, col)
m = np.concatenate((zero_m,cur_m),axis=1)
sum_m = np.concatenate((sum_m,m),axis=1)
printMatrix(sum_m)
using System;
using System.Collections.Generic;
namespace CD003
{
class Program
{
static void Main(string[] args)
{
string result = string.Empty;
string[] input = new string[2];
while (true)
{
input = Console.ReadLine().Split();
if (input[0] == "0" && input[1] == "0") { break; }
result += ToLCDString(input[0], input[1]) + Environment.NewLine;
}
Console.WriteLine(result);
}
// LCD 문자열 출력
static string ToLCDString(string scaleStr, string numbersStr)
{
string result = string.Empty;
int scale = int.Parse(scaleStr);
int length = 3 + scale * 2; // LCD 문자의 높이(리스트 용량)
var LCDList = new List<string>(); // 여러 숫자의 LCD 문자열
for (int i = 0; i < length; i++) { LCDList.Add(String.Empty); }
foreach (var val in numbersStr)
{
LCD lcd = new LCD((int)Char.GetNumericValue(val), scale);
for (var idx = 0; idx < length; idx++)
{
LCDList[idx] += lcd[idx] + " ";
}
}
for (var idx = 0; idx < length; idx++)
{
result += LCDList[idx] + Environment.NewLine;
}
return result;
}
}
class LCD
{
// 숫자 -> LCD
// h: -, n: 빈칸, l: 왼쪽 | , r: 오른쪽 |, b: 양쪽 ||
private static Dictionary<int, string> Dic = new Dictionary<int, string>()
{
{0, "hbnbh" },{1, "nrnrn" },{2, "hrhlh" },{3, "hrhrh" },{4, "nbhrn" },
{5, "hlhrh" },{6, "hlhbh" },{7, "hrnrn" },{8, "hbhbh" },{9, "hbhrh" },
};
private static string LCDLine(char type, int scale)
{
string result = string.Empty;
switch (type)
{
case 'h':
result = " " + new string('-', scale) + " ";
break;
case 'b':
result = "|" + new string(' ', scale) + "|";
break;
case 'l':
result = "|" + new string(' ', scale) + " ";
break;
case 'r':
result = " " + new string(' ', scale) + "|";
break;
case 'n':
result = " " + new string(' ', scale) + " ";
break;
}
return result;
}
// 1개의 숫자 및 크기에 대한 LCD 문자열 리스트
private List<string> LCDString = new List<string>();
public LCD(int aNumber, int scale)
{
for (int idx = 0; idx < Dic[aNumber].Length; idx++)
{
if (idx % 2 == 0)
{
LCDString.Add(LCDLine(Dic[aNumber][idx], scale));
}
else
{
for (int i = 0; i < scale; i++)
{
LCDString.Add(LCDLine(Dic[aNumber][idx], scale));
}
}
}
}
public string this[int row] => LCDString[row];
}
}
def LCD_num(s,n):
r = [' '+'-'*s+' ' for i in range(2*s+3)]
if n in (1,4): r[0] = ' '*(s+2)
for i in range(1,s+1):
if n in (5,6): r[i] = '|'+' '*(s+1)
elif n in (1,2,3,7): r[i] = ' '*(s+1)+'|'
else: r[i] = '|'+' '*s+'|'
if n in (1,7,0): r[s+1] = ' '*(s+2)
for i in range(s+2,2*s+2):
if n in (2,): r[i] = '|'+' '*(s+1)
elif n in (6,8,0): r[i] = '|'+' '*s+'|'
else: r[i] = ' '*(s+1)+'|'
if n in (1,4,7): r[2*s+2] = ' '*(s+2)
return r
def LCD_print(a):
s,nums = a
for i in str(nums):
tmp = LCD_num(s,int(i))
if 'result' not in locals(): result = tmp[:]
else:
for i in range(len(tmp)): result[i] += ' '+tmp[i]
for i in range(len(result)): print(result[i])
return result
# 입력
m = []
while 1:
m.append(tuple(map(int, input().split())))
if m[-1] == (0, 0):
del m[-1]
break
for i in m: LCD_print(i)
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
흠... 저런 코드는 도대체 어디서 나오는 건지 모르겠네요 ㅠㅠㅠ 세상은 넓네요 저는 딱 요정도 수준 ㅠㅠㅠ...
# 0은 없다
# 1은 하이픈
# 2는 왼쪽 파이프
# 3은 오른쪽 파이프
# 5는 양쪽 파이프(2+3)
arr = ['15051','03030','13121','13131','05130','12131','12151','13030','15151','15131']
def text(n):
return [' '*(n+2) , ' ' + '-' * n + ' ', '|' + ' ' * (n+1), ' ' * (n+1) + '|', '','|' + ' '*(n) + '|']
a = 1
while(a):
a, b = input().split()
s = int(a)
t = text(s)
data = dict()
for b1 in b:
data[b1] = []
for a in arr[int(b1)]:
data[b1].append(t[int(a)])
p1 = ''
for i in range(5):
a = s if i in [1,3] else 1
for j in range(a):
for key in data.keys():
p1 += data[key][i] + ' '
p1 += '\n'
print(p1)
def LCD(l,n):
n = list(str(n))
for x in range(5):
lis = []
if x in [0,2,4]:
for f in n:
lis.append(' ')
lis.append(' ' * l if (f=='1')or(f=='4' and x!=2)or(f=='7' and x!=0)or(f=='0' and x==2) else '#' * l)
lis.append(' ')
else:
for f in n:
if x == 1:
lis.append('#'+' '*(l+1) if f in ['1','5','6'] else ' '*(l+1)+'#' if f in ['2','3','7'] else '#'+' '*l+'#')
lis.append(' ')
else:
lis.append('#'+' '*(l+1) if f in ['1','2'] else ' '*(l+1)+'#' if f in ['3','4','5','7','9'] else '#'+' '*l+'#')
lis.append(' ')
lis.append(' ')
lis.append('\n')
print(''.join(lis) if x in [0,2,4] else ''.join(lis*l), end = '')
feature_num={'0':set([1,6,7,3,5,4]),'1':set([6,7]),'2':set([1,6,2,5,3]),'3':set([1,6,2,7,3]),'4':set([4,2,6,7]),'5':set([1,4,2,7,3]),'6':set([1,4,5,3,7,2]),'7':set([1,6,7]),'8':set([1,2,3,4,5,6,7]),'9':set([4,1,6,2,7,3])}
def draw_num(fletter,fsize,fresult):
temp=''
index=0
#step1
if 1 in feature_num[fletter]:
temp = ' ' + '-'*fsize
temp+=' '
else:
temp = ' '*(fsize+2)
fresult[index]+=temp
index+=1
#step2
if 4 in feature_num[fletter]:
temp = 'l' + ' '*fsize
else:
temp = ' '*(fsize+1)
if 6 in feature_num[fletter]:
temp += 'l'
else:
temp +=' '
for ii in range(fsize):
fresult[index] += temp
index+=1
#step3
if 2 in feature_num[fletter]:
temp = ' ' + '-'*fsize
temp+=' '
else:
temp = ' '*(fsize+2)
fresult[index]+=temp
index+=1
#step4
if 5 in feature_num[fletter]:
temp = 'l' + ' '*fsize
else:
temp = ' '*(fsize+1)
if 7 in feature_num[fletter]:
temp += 'l'
else:
temp +=' '
for ii in range(fsize):
fresult[index] += temp
index+=1
#step5
if 3 in feature_num[fletter]:
temp = ' ' + '-'*fsize
temp+=' '
else:
temp = ' '*(fsize+2)
fresult[index]+=temp
for iii in range(2*fsize+3):
fresult[iii]+=' '
def draw_num_string():
size,num_string=input().split(' ')
size=int(size)
arr_size=2*size+3
result=['']*arr_size
for letter in num_string:
draw_num(letter,size,result)
for i in range(arr_size):
print(result[i])
draw_num_string()
public class LCD3 {
public static String[] POSITION = {"1011011111","21112001222","0011111011","2101112121","1011011011"};
public static int S,N;
public static void main(String[] args) {
setting();
printLCD();
}
public static void printLCD() {
String numbers[] = String.valueOf(N).split("");
int top = 0;
int mid = (3+S*2)/2;
int bottom = (3+S*2)-1;
for(int i=0;i<3+S*2;i++) {
for(int j=0;j<numbers.length;j++) {
int number = Integer.parseInt(numbers[j]);
if(i==top) {
printDigitPartAboutTopMidBottom(0,number);
}else if(i<mid) {
printDigitPartAboutBetween(1, number);
}else if(i==mid) {
printDigitPartAboutTopMidBottom(2,number);
}else if(i<bottom) {
printDigitPartAboutBetween(3, number);
}else {
printDigitPartAboutTopMidBottom(4,number);
}
System.out.print(" ");
}
System.out.println();
}
}
private static void setting() {
Scanner sc = new Scanner(System.in);
S = sc.nextInt();
N = sc.nextInt();
sc.close();
}
private static void printDigitPartAboutBetween(int pos, int number) {
int temp = POSITION[pos].charAt(number) - 0x30;
if(temp == 0 || temp == 2) {
System.out.print("|");
}else {
System.out.print(" ");
}
printChar(' ',S);
if(temp == 1 || temp == 2) {
System.out.print("|");
} else {
System.out.print(" ");
}
}
private static void printDigitPartAboutTopMidBottom(int pos, int number) {
int temp = POSITION[pos].charAt(number) - 0x30;
System.out.print(" ");
if(temp == 1) {
printChar('-',S);
} else {
printChar(' ',S);
}
System.out.print(" ");
}
private static void printChar(char c, int size) {
for(int i=0;i<size;i++) {
System.out.print(c);
}
}
}
class draw_line:
def upper_vertical(pos, s, board):
for i in range(1, (2*s+3)//2):
board[i][pos] = '|'
def lower_vertical(pos, s, board):
for i in range(((2*s+3)//2)+1, 2*s+2):
board[i][pos] = '|'
def horizon(s, i, board, row):
for i in range( ((s+2)*i)+1, (s+2)*(i+1)-1 ):
board[row][i] = '-'
def ch_LCD_display(s, i, ch, board):
if(ch in ['2','3','5','6','7','8','9','0']):
draw_line.horizon(s, i, board, 0)
if(ch in ['2','3','4','5','6','8','9']):
draw_line.horizon(s, i, board, (2*s+3)//2)
if(ch in ['2','3','5','6','8','9','0']):
draw_line.horizon(s, i, board, 2*s+2)
if(ch in ['4','5','6','8','9','0']):
draw_line.upper_vertical((s+2)*(i), s, board)
if(ch in ['2','6','8','0']):
draw_line.lower_vertical((s+2)*(i), s, board)
if(ch in ['1','2','3','4','7','8','9','0']):
draw_line.upper_vertical((s+2)*(i+1)-1 , s, board)
if(ch in ['1','3','4','5','6','7','8','9','0']):
draw_line.lower_vertical((s+2)*(i+1)-1 , s, board)
def LCD_display(s, n):
n_to_list = list(n)
index=0 #각 문자의 위치
board = [[' ']*((s+2)*len(n_to_list)) for i in range(2*s+3)] #전체 display board
for ch in n_to_list: #한 문자씩 출력
ch_LCD_display(s, index, ch, board)
index += 1
for row in board:
for el in row:
print(el, end="")
print()
#main
while(True):
s, n = input().split(); s = int(s) #입력구간. s는 display크기, n은 출력할 숫자
if(s == 0 and n == '0'): break
LCD_display(s, n) #0 0이 아니면 출력
def setLcd(sArray, s, n):
sH, sW = (s*2) + 3, s + 2
sArray = [[" "] * sW for i in range(sH)]
return sArray
def onLcd(sArray, s, n):
hNum = 0
wCount = 0
w1,w2,w3 = [2, 3, 5,6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 8, 9], [2, 3, 5, 6, 8, 0]
h1,h2,h3,h4 = [4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 7, 8, 9, 0], [2, 6, 8, 0], [1, 3, 4, 5, 6, 7, 8, 9, 0]
# insert Lcd string
while hNum < (s*2) + 3:
if hNum % (s+1) == 0:
if wCount == 0 and n in w1:
for i in range(1,s+1): sArray[hNum][i] = "-"
if wCount == 1 and n in w2:
for i in range(1,s+1): sArray[hNum][i] = "-"
if wCount == 2 and n in w3:
for i in range(1,s+1): sArray[hNum][i] = "-"
wCount += 1
else:
if n in h1:
for i in range(1,s+1): sArray[i][0] = "|"
if n in h2:
for i in range(1,s+1): sArray[i][s+1] = "|"
if n in h3:
for i in range(1+(s+1),2*(s+1)): sArray[i][0] = "|"
if n in h4:
for i in range(1+(s+1),2*(s+1)): sArray[i][s+1] = "|"
hNum+=1
return sArray
s, m = input().split()
s = int(s)
m = [int(m) for m in m]
result = []
for i in range(len(m)):
n = m[i]
sArray = []
sArray = setLcd(sArray,s,n)
sArray = onLcd(sArray, s, n)
result.append(sArray)
for i in range(s*2+3):
for k in range(len(result)):
for j in range(s+2):
print(result[k][i][j],end="")
print(" ",end='')
print("")
Python3.6
파이썬3입니다.
import numpy as np
def num_lcd(s, n):
result = np.zeros((2*s+3, s+2))
if n in [2, 3, 5, 6, 7, 8, 9, 0]:
result[0, 1:-1] = 1
if n in [4, 5, 6, 8, 9, 0]:
result[1:s+1, 0] = 2
if n in [1, 2, 3, 4, 7, 8, 9, 0]:
result[1:s+1, -1] = 2
if n in [2, 3, 4, 5, 6, 8, 9]:
result[s+1, 1:-1] = 1
if n in [2, 6, 8, 0]:
result[s+2:-1, 0] = 2
if n in [1, 3, 4, 5, 6, 7, 8, 9, 0]:
result[s+2:-1, -1] = 2
if n in [2, 3, 5, 6, 8, 0]:
result[-1, 1:-1] = 1
return result
def lcd(s, n):
num_list = list(map(int, list(str(n))))
length = len(num_list)
result = np.zeros((2*s+3, (s+3)*length-1), dtype=int)
for i in range(length):
result[:, (s+3)*i:(s+3)*(i+1)-1] = num_lcd(s, num_list[i])
result = str(result).replace('[', ' ').replace(']', ' ').replace(' ', '')\
.replace('0', ' ').replace('1', '-').replace('2', '|')
print(result, end='\n\n')
def get_data():
sn_list = []
while True:
try:
s, n = list(map(int, input('s, n : ').split()))
if s == n == 0:
break
sn_list.append((s, n))
except:
print('error')
return sn_list
if __name__ == '__main__':
for sn in get_data():
lcd(*sn)
s, n : >? 2 12345
s, n : >? 3 67890
s, n : >? 0 0
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
#include <iostream>
using namespace std;
int main()
{
const char a[]={119,3,62,31,75,93,125,19,127,95};
char numbers[10]={0,};
int s, n, d;
cin >> s >> n;
cin.clear();
cout <<endl;
while(s){
d=0;
if (s==0&&n==0) break;
if (s==0) {
cin>>s >> n;
continue;
}
for(int i=1;i<n;i*=10) d++;
for(int i=0;i<d;i++){
numbers[d-i-1]=n%10;
n/=10;
}
for(int i=0;i<d;i++){
cout <<" ";
for(int j=0;j<s;j++) {
if(a[numbers[i]]&16) cout<<'-';
else cout<<' ';
}
cout <<" ";
}
cout<<endl;
for(int i=0;i<s;i++){
for(int j=0;j<d;j++)
{
if(a[numbers[j]]&64) cout<<'|';
else cout<<' ';
for(int k=0;k<s;k++)cout<<' ';
if(a[numbers[j]]&2) cout<<'|';
else cout<<' ';
cout<<' ';
}
cout<<endl;
}
for(int i=0;i<d;i++){
cout <<" ";
for(int j=0;j<s;j++) {
if(a[numbers[i]]&8) cout<<'-';
else cout<<' ';
}
cout <<" ";
}
cout<<endl;
for(int i=0;i<s;i++){
for(int j=0;j<d;j++)
{
if(a[numbers[j]]&32) cout<<'|';
else cout<<' ';
for(int k=0;k<s;k++)cout<<' ';
if(a[numbers[j]]&1) cout<<'|';
else cout<<' ';
cout<<' ';
}
cout<<endl;
}
for(int i=0;i<d;i++){
cout <<" ";
for(int j=0;j<s;j++) {
if(a[numbers[i]]&4) cout<<'-';
else cout<<' ';
}
cout <<" ";
}
cout<<endl;
cin >> s >> n;
}
return 1 ;
}
def draw_num(size, num):
drawing = {'1': '36', '2': '13457', '3': '13467', '4': '2346', '5': '12467', '6': '124567', '7': '136', '8': '1234567', '9': '123467', '0': '123567'}
result = ''
for line in range(size * 2 + 3):
for i, write in enumerate(num):
if line == 0 or line == size + 1 or line == size * 2 + 2:
step = ''
if line == 0:
step = '1'
elif line == size + 1:
step = '4'
else:
step = '7'
result += ' '
if step in drawing[write]:
result += '-' * size
else:
result += ' ' * size
if i < len(num) - 1:
result += ' '
elif line < size + 1:
if '2' in drawing[write]:
result += '|' + ' ' * size
else:
result += ' ' * (size + 1)
if '3' in drawing[write]:
result += '|'
else:
result += ' '
if i < len(num) - 1:
result += ' '
else:
if '5' in drawing[write]:
result += '|' + ' ' * size
else:
result += ' ' * (size + 1)
if '6' in drawing[write]:
result += '|'
else:
result += ' '
if i < len(num) - 1:
result += ' '
result += '\n'
return result
got = []
a = ''
while a != '0 0':
a = input()
got.append([int(a.split()[0]), a.split()[1]])
del got[-1]
for pr in got:
print(draw_num(pr[0], pr[1]))
디지털 숫자의 전등 7개를 1~7까지의 숫자로 표현하고, drawing 변수에 0~9까지의 숫자마다 어떤 전등을 켜야 하는지 딕셔너리 형태로 입력한 뒤 전체 숫자 문자열 7줄을 차례대로 나타내는 코드입니다.
# 0~9까지의 숫자 만들기
def one(n): # 파라미터에 배율 넣기
number = []
for x in range(2*n+3):
number.append(' | ')
for x in range(0, 2*n+3, n+1):
number[x] = ''
return number
def two(n):
number = []
number.append(' ' + '-'*n + ' ')
for x in range(n):
number.append(' '*(n+1) + '|')
number.append(' ' + '-'*n + ' ')
for x in range(n):
number.append('|' + ' '*(n+1))
number.append(' ' + '-' * n + ' ')
return number
def three(n):
number = []
number.append(' ' + '-'*n + ' ')
for x in range(n):
number.append(' '*(n+1) + '|')
number.append(' ' + '-'*n + ' ')
for x in range(n):
number.append(' '*(n+1) + '|')
number.append(' ' + '-' * n + ' ')
return number
def four(n):
number = []
number.append(' '*(n+2))
for x in range(n):
number.append('|' + ' '*n + '|')
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append(' '*(n+1) + '|')
number.append(' ' * (n + 2))
return number
def five(n):
number = []
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append('|' + ' ' * (n + 1))
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append(' ' * (n + 1) + '|')
number.append(' ' + '-' * n + ' ')
return number
def six(n):
number = []
number.append(' ' + '-'*n + ' ')
for x in range(n):
number.append('|' + ' '*(n + 1))
number.append(' ' + '-'*n + ' ')
for x in range(n):
number.append('|' + ' '*n + '|')
number.append(' ' + '-'*n + ' ')
return number
def seven(n):
number = []
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append('|' + ' '*n + '|')
number.append(' ' * (n + 2))
for x in range(n):
number.append(' ' * (n + 1) + '|')
number.append(' ' * (n + 2))
return number
def eight(n):
number = []
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append('|' + ' ' * n + '|')
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append('|' + ' ' * n + '|')
number.append(' ' + '-' * n + ' ')
return number
def nine(n):
number = []
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append('|' + ' ' * n + '|')
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append(' ' * (n + 1) + '|')
number.append(' ' * (n + 2))
return number
def zero(n):
number = []
number.append(' ' + '-' * n + ' ')
for x in range(n):
number.append('|' + ' ' * n + '|')
number.append(' ' * (n + 2))
for x in range(n):
number.append('|' + ' ' * n + '|')
number.append(' ' + '-' * n + ' ')
return number
size = 1
while size:
# 사이즈와 숫자 입력 받기
enter = input("size number ")
size = int(enter.split()[0])
count = len(enter.split()[1])
# 숫자와 숫자만드는 함수를 매칭
digit_number = {'1': one(size), '2': two(size), '3': three(size), '4': four(size), '5': five(size),
'6': six(size), '7': seven(size), '8': eight(size), '9': nine(size), '0': zero(size)}
number = []
for x in enter.split()[1]:
number.append(digit_number.get(x))
# 각 숫자의 행을 하나의 행으로 묶기
result = []
for x in range(2 * size + 3):
line = ''
n = 0
while n < count:
line = line + number[n][x] + ' '
n += 1
result.append(line)
for x in result:
print(x)
def first(number,s):
if number in {1,4}:
return ' '*(s+2)
if number in {2,3,5,6,7,8,9,0}:
return ' ' + '-'*s + ' '
def intermediate_above(number,s):
if number in {1,2,3,7}:
return ' '*(s+1) + '|'
if number in {4,8,9,0}:
return '|' + ' '*s + '|'
if number in {5,6}:
return '|' + ' '*(s+1)
def middle(number, s):
if number in {1,7,0}:
return ' '*(s+2)
else:
return ' ' + '-'*s + ' '
def intermediate_below(number,s):
if number in {1,3,4,5,7,9}:
return ' '*(s+1) + '|'
if number in {6,8,0}:
return '|' + ' '*s + '|'
if number in {2}:
return '|' + ' '*(s+1)
def last(number,s):
if number in {1,4,7}:
return ' '*(s+2)
else:
return ' ' + '-'*s + ' '
def writing(s, string_num):
for i in range(1,2*s+4):
if i == 1:
result = ''
for x in str(string_num):
result = result + first(int(x),s)+' '
print(result)
if i in range(2,s+2):
result = ''
for x in str(string_num):
result = result + intermediate_above(int(x),s)+' '
print(result)
if i == s+2:
result = ''
for x in str(string_num):
result = result+ middle(int(x),s)+' '
print(result)
if i in range(s+3,2*s+3):
result = ''
for x in str(string_num):
result = result + intermediate_below(int(x),s)+' '
print(result)
if i == 2*s + 3:
result = ''
for x in str(string_num):
result = result + last(int(x),s)+' '
print(result)
def LCD_display(List):
for i in range(0,len(List)):
n,m = List[i]
writing(n,m)
LCD_display([(4,12345),(3,6789012)])
d0 = [1,0,1,1,0,1,1,1,1,1]
d1 = [(1,1),(0,1),(0,1),(0,1),(1,1),(1,0),(1,0),(0,1),(1,1),(1,1)]
d2 = [0,0,1,1,1,1,1,0,1,1]
d3 = [(1,1),(0,1),(1,0),(0,1),(0,1),(0,1),(1,1),(0,1),(1,1),(0,1)]
d4 = [1,0,1,1,0,1,1,0,1,1]
data = [d0, d1, d2, d3, d4]
def print_num(size, n):
L = [int(i) for i in str(n)]
for k, d in enumerate(data):
if k % 2 == 0:
for idx, i in enumerate(L):
s = ' ' + [' ', '-'][d[i]] * size + ' '
if idx < len(L) - 1: e = ' '
else: e = '\n'
print(s, end=e)
else:
for _ in range(size):
for idx, i in enumerate(L):
s = [' ', '|'][d[i][0]] + ' ' * size + [' ', '|'][d[i][1]]
if idx < len(L) - 1: e = ' '
else: e = '\n'
print(s, end=e)
print_num(2, 1234)
print_num(3, 67890)
파이썬 3.7.2
import sys
def LCD(mp: list):
result = ""
for x in mp:
for y in x:
if y == 0:
result += " "
elif y == 1:
result += "-"
elif y == 2:
result += "|"
result += "\n"
return result
S, N = [], []
while True:
s, n = input("> ").split(" "); s, n = int(s), int(n)
if s == 0 and n == 0:
break
S.append(s)
N.append(n)
del s, n
for x in S:
if x < 1 or x >= 10:
print("s의 범위가 벗어났습니다")
sys.exit()
for x in N:
if x < 0 or x > 99999999:
print("n의 범위가 벗어났습니다")
sys.exit()
for i in range(len(S)):
result = []
for x in range(2*S[i]+3):
result.append([])
for y in range((S[i]+3)*len(str(N[i]))):
result[x].append(0)
for x in range(len(str(N[i]))):
if str(N[i])[x] == "1":
for y in range(S[i]):
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
if str(N[i])[x] == "2":
for y in range(S[i]): #ing
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[S[i]+1][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "3":
for y in range(S[i]):
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[S[i]+1][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "4":
for y in range(S[i]):
result[y+1][x*(S[i]+3)] = 2
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[S[i]+1][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "5":
for y in range(S[i]):
result[y+1][x*(S[i]+3)] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[S[i]+1][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "6":
for y in range(S[i]):
result[y+1][x*(S[i]+3)] = 2
result[y+S[i]+2][x*(S[i]+3)] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[S[i]+1][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "7":
for y in range(S[i]):
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "8":
for y in range(S[i]):
result[y+1][x*(S[i]+3)] = 2
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[S[i]+1][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "9":
for y in range(S[i]):
result[y+1][x*(S[i]+3)] = 2
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[S[i]+1][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
if str(N[i])[x] == "0":
for y in range(S[i]):
result[y+1][x*(S[i]+3)] = 2
result[y+1][x*(S[i]+3)+S[i]+1] = 2
result[y+S[i]+2][x*(S[i]+3)] = 2
result[y+S[i]+2][x*(S[i]+3)+S[i]+1] = 2
result[0][x*(S[i]+3)+y+1] = 1
result[2*S[i]+2][x*(S[i]+3)+y+1] = 1
print(LCD(result))
table_number = {
'0': [[4,2,4,4],[1,5,1,4],[4,0,4,4],[1,5,1,4],[4,2,4,4]],
'1' : [[4,0,4,4],[0,5,1,4],[4,0,4,4],[0,5,1,4],[4,0,4,4]],
'2' : [[4,2,4,4],[0,5,1,4],[4,2,4,4],[1,5,0,4],[4,2,4,4]],
'3' : [[4,2,4,4],[0,5,1,4],[4,2,4,4],[0,5,1,4],[4,2,4,4]],
'4' : [[4,0,4,4],[1,5,1,4],[4,2,4,4],[0,5,1,4],[4,0,4,4]],
'5' : [[4,2,4,4],[1,5,0,4],[4,2,4,4],[0,5,1,4],[4,2,4,4]],
'6' : [[4,2,4,4],[1,5,0,4],[4,2,4,4],[1,5,1,4],[4,2,4,4]],
'7' : [[4,2,4,4],[1,5,1,4],[4,0,4,4],[0,5,1,4],[4,0,4,4]],
'8' : [[4,2,4,4],[1,5,1,4],[4,2,4,4],[1,5,1,4],[4,2,4,4]],
'9' : [[4,2,4,4],[1,5,1,4],[4,2,4,4],[0,5,1,4],[4,0,4,4]]
}
table_segment={0:' ', 1:'|', 2:'-', 4: ' ',5: ' '}
while True :
s_input, input_number = input().split()
s = int(s_input)
if s==0 & int(input_number)==0 :
exit()
elif s==0 :
print ("wrong access")
exit()
segment_value = {}
for c in range(len(input_number)) :
segment_value[c] = table_number[input_number[c]]
metrix = [[0 for x_len in range(len(input_number)*4)]for y_len in range(5)]
for k in range(len(input_number)) :
for b in range(5) :
for a in range(4):
metrix[b][4*k+a] = segment_value[k][b][a]
for y in range(5) :
if y%2 == 1 :
for val_s in range(s) :
for x in range(len(input_number)*4):
if metrix[y][x] == 5:
for val_k in range(s) :
print(' ',end ='')
else :
print(table_segment[metrix[y][x]],end='')
print()
else :
for x in range(len(input_number)*4) :
if metrix[y][x] == 4 :
print(' ',end ='')
else:
for val_s in range(s) :
print(table_segment[metrix[y][x]],end='')
print()
0~9까지의 값을 각각 4x5의 세그먼트로 작성후, 하나의 행렬로 병합, 한줄씩 출력하는 형식입니다.
0 = ' ' // 1,3,5 번째 일반 공백 값 1 = '|' //1,3,5 번째 값 2='-'//2,4 번째 값 4 = ' '//반복 되지않는 공백 값 5 = ' '//2,4 번째 반복되는 공백 값
'-',' ','|' 이렇게 component를 배열에 넣으니까 "%c"로 출력할때 한문이 나오네요.. "- |"이런식으로 넣어야 인식하네요... 제 환경 문제일까요? ㅠ
#include "pch.h"
#include <iostream>
#include <stdio.h>
char nnn[4] = " ";
char n_n[4] = " - ";
char ini[4] = "| |";
char nni[4] = " |";
char inn[4] = "| ";
char *s0[10] = { n_n, nnn, n_n, n_n, nnn, n_n, n_n, n_n, n_n, n_n };
char *s1[10] = { ini, nni, nni, nni, ini, inn, inn, ini, ini, ini };
char *s2[10] = { nnn, nnn, n_n, n_n, n_n, n_n, n_n, nnn, n_n, n_n };
char *s3[10] = { ini, nni, inn, nni, nni, nni, ini, nni, ini, nni };
char *s4[10] = { n_n, nnn, n_n, n_n, nnn, n_n, n_n, nnn, n_n, n_n };
void printS0(int s, char* digit, int len)
{
for (int j = 0; j < len; j++)
{
printf("%c", s0[digit[j] - '0'][0]);
for (int i = 0; i < s; i++)
{
printf("%c", s0[digit[j] - '0'][1]);
}
printf("%c", s0[digit[j] - '0'][2]);
}
printf("\n");
}
void printS1(int s, char* digit, int len)
{
for (int j = 0; j < len; j++)
{
printf("%c", s1[digit[j] - '0'][0]);
for (int i = 0; i < s; i++)
{
printf("%c", s1[digit[j] - '0'][1]);
}
printf("%c", s1[digit[j] - '0'][2]);
}
printf("\n");
}
void printS2(int s, char* digit, int len)
{
for (int j = 0; j < len; j++)
{
printf("%c", s2[digit[j] - '0'][0]);
for (int i = 0; i < s; i++)
{
printf("%c", s2[digit[j] - '0'][1]);
}
printf("%c", s2[digit[j] - '0'][2]);
}
printf("\n");
}
void printS3(int s, char* digit, int len)
{
for (int j = 0; j < len; j++)
{
printf("%c", s3[digit[j] - '0'][0]);
for (int i = 0; i < s; i++)
{
printf("%c", s3[digit[j] - '0'][1]);
}
printf("%c", s3[digit[j] - '0'][2]);
}
printf("\n");
}
void printS4(int s, char* digit, int len)
{
for (int j = 0; j < len; j++)
{
printf("%c", s4[digit[j] - '0'][0]);
for (int i = 0; i < s; i++)
{
printf("%c", s4[digit[j] - '0'][1]);
}
printf("%c", s4[digit[j] - '0'][2]);
}
printf("\n");
}
int main()
{
int s;
int len;
char abc[256];
scanf("%d %s", &s, abc);
len = strlen(abc);
printS0(s, abc, len);
for (int a = 0; a < s; a++)
{
printS1(s, abc, len);
}
printS2(s, abc, len);
for (int a = 0; a < s; a++)
{
printS3(s, abc, len);
}
printS4(s, abc, len);
}
inputList = ["5 12345", "4 67890", "0 0"]
numPattern = [[" - ","| |"," ","| |"," - "],
[" "," |"," "," |"," "],
[" - "," |"," - ","| "," - "],
[" - "," |"," - "," |"," - "],
[" ","| |"," - "," |"," "],
[" - ","| "," - "," |"," - "],
[" - ","| "," - ","| |"," - "],
[" - "," |"," "," |"," "],
[" - ","| |"," - ","| |"," - "],
[" - ","| |"," - "," |"," - "]
]
for x in inputList:
param = x.split(" ")
s, n = int(param[0]), int(param[1])
if s == 0 and n == 0:
break
digits = len(param[1])
lcd = [[""] for j in range(s*2+3)]
for dStr in param[1]:
y = 0
d = int(dStr)
for k in range(5):
for j in range(s if k%2==1 else 1):
lcd[y+j][0] += numPattern[d][k][0]
for i in range(s):
lcd[y+j][0] += numPattern[d][k][1]
lcd[y+j][0] += numPattern[d][k][2]
if dStr != param[1][len(param[1])-1]:
lcd[y+j][0] += " "
y += (j+1)
for x in lcd:
print(x)
seven segment 모양을 기반으로 알고리즘을 세워보았습니다.
void main() {
int c, s, len_n, zero;
int *input, temp1;
char *num[10];
char *n = (char*)malloc(sizeof(char) * 15);
//seven segment를 단순화해서 각 숫자별로 저장함.
num[0] = "12021\n";
num[1] = "01010\n";
num[2] = "11101\n";
num[3] = "11111\n";
num[4] = "02110\n";
num[5] = "10111\n";
num[6] = "10121\n";
num[7] = "11010\n";
num[8] = "12121\n";
num[9] = "12111\n";
while (1) { // 반복처리
printf("입력:");
scanf("%d, %s", &s, n);
zero= atoi(&n[0])-atoi(&n[1]); //첫자리가 0인지 확인
temp1 = atoi(&n[0]), len_n = 0;
while (temp1 > 0) { // 숫자 n의 자리수 확인
temp1 = temp1 / 10;
len_n++;
}
if (!zero) { //첫자리 0이면 길이 추가
len_n++;
}
input = (int*)malloc(sizeof(int)*len_n); // 문자열 → 정수
temp1 = atoi(&n[0]);
for (int i = len_n - 1; i > -1; i--) { //숫자 자리수 쪼개기
input[i] = temp1 % 10;
temp1 = temp1 / 10;
printf("%d, %d \n", input[i], i);
}
int k = 0;
while (k < 5 && s>0) {
if (k % 2 == 0) { //가로막대 출력 (---)
for (int i = 0; i < len_n; i++) {
printf(" ");
for (int j = 0; j < s; j++) { //S만큼 반복 출력
if (num[input[i]][k] == 49) { //ASCII CODE 1 구분
printf("-");
}
else {
printf(" ");
}
}
printf(" ");
}
printf("\n");
}
else { // 세로막대 출력(|)
for (int z = 0; z < s; z++) { //S만큼 세로방향 반복 출력
for (int i = 0; i < len_n; i++) {
if (num[input[i]][k] % 2 == 1) { //ASCII COSE 0, 2구분
printf(" ");
}
else {
printf("|");
}
for (int y = 0; y < s; y++) { //S만큼 가로방향 반복 출력
printf(" ");
}
if (num[input[i]][k] == 48) { //ASCII CODE 0 구분
printf(" ");
}
else {
printf("|");
}
}
printf("\n");
}
}
k++;
}
}
scanf_s("%d", &c);
}
namespace codingdojang__
{
class Program
{
static void Main(string[] args)
{
Lcd(2, "12345");
Lcd(3, "67890");
Lcd(5, "1234567890");
Lcd(0, "0");
}
static void Lcd(int s, string n)
{
if (s != 0 && int.Parse(n) != 0)
{
for (int column = 1; column <= 2 * s + 3; column++)
{
if (column == 1)
{
for (int i = 0; i < n.Length; i++)
{
if (int.Parse(n[i].ToString()) == 1 || int.Parse(n[i].ToString()) == 4)
{
Console.Write(" ");
for (int row = 0; row < s; row++)
{
Console.Write(" ");
}
Console.Write(" ");
}
else
{
Console.Write(" ");
for (int row = 0; row < s; row++)
{
Console.Write("-");
}
Console.Write(" ");
}
}
Console.WriteLine();
}
else if (column == Math.Ceiling((2 * s + 3) / 2.0))
{
for (int i = 0; i < n.Length; i++)
{
if (int.Parse(n[i].ToString()) == 1 || int.Parse(n[i].ToString()) == 0 || int.Parse(n[i].ToString()) == 7)
{
Console.Write(" ");
for (int row = 0; row < s; row++)
{
Console.Write(" ");
}
Console.Write(" ");
}
else
{
Console.Write(" ");
for (int row = 0; row < s; row++)
{
Console.Write("-");
}
Console.Write(" ");
}
}
Console.WriteLine();
}
else if (column == 2 * s + 3)
{
for (int i = 0; i < n.Length; i++)
{
if (int.Parse(n[i].ToString()) == 1 || int.Parse(n[i].ToString()) == 4 || int.Parse(n[i].ToString()) == 7)
{
Console.Write(" ");
for (int row = 0; row < s; row++)
{
Console.Write(" ");
}
Console.Write(" ");
}
else
{
Console.Write(" ");
for (int row = 0; row < s; row++)
{
Console.Write("-");
}
Console.Write(" ");
}
}
Console.WriteLine();
}
else
{
if (column < Math.Ceiling((2 * s + 3) / 2.0))
{
for (int i = 0; i < n.Length; i++)
{
if (int.Parse(n[i].ToString()) == 1 || int.Parse(n[i].ToString()) == 2 || int.Parse(n[i].ToString()) == 3 || int.Parse(n[i].ToString()) == 7)
{
for (int e = 0; e < s + 1; e++)
{
Console.Write(" ");
}
Console.Write("|");
Console.Write(" ");
}
else if (int.Parse(n[i].ToString()) == 6 || int.Parse(n[i].ToString()) == 5)
{
Console.Write("|");
for (int e = 0; e < s + 1; e++)
{
Console.Write(" ");
}
Console.Write(" ");
}
else
{
Console.Write("|");
for (int e = 0; e < s; e++)
{
Console.Write(" ");
}
Console.Write("|");
Console.Write(" ");
}
}
Console.WriteLine();
}
else
{
for (int i = 0; i < n.Length; i++)
{
if (int.Parse(n[i].ToString()) == 6 || int.Parse(n[i].ToString()) == 8 || int.Parse(n[i].ToString()) == 0)
{
Console.Write("|");
for (int e = 0; e < s; e++)
{
Console.Write(" ");
}
Console.Write("|");
Console.Write(" ");
}
else if (int.Parse(n[i].ToString()) == 2)
{
Console.Write("|");
for (int e = 0; e < s + 1; e++)
{
Console.Write(" ");
}
Console.Write(" ");
}
else
{
for (int e = 0; e < s + 1; e++)
{
Console.Write(" ");
}
Console.Write("|");
Console.Write(" ");
}
}
Console.WriteLine();
}
}
}
}
}
}
}
def make_num(s, n):
a=' '*(s+2);b=('-'*s).center(s+2, ' ')
c='|'.rjust(s+2);d='|'.ljust(s+2);e=(' '*s).center(s+2, '|')
nums={'1':'acaca', '2':'bcbdb', '3':'bcbcb', '4':'aebca', '5':'bdbcb',
'6':'bdbeb', '7':'beaca', '8':'bebeb', '9':'bebcb', '0':'beaeb'}
for i in range(5):
r=''
for k in n:
r+=eval(nums[k][i])
if i%2==0: print(r)
else:
for i in range(s):
print(r)
while True:
s,n=input().split(' ')
make_num(int(s), n)
print('\n')
PHP
$fn = function(int $s, int $n) : string {
if (!(1 <= $s && $s < 10) || !(0 <= $n && $n <= 99999999)) return '';
$arr = [
0 => [1, 1, 1, 0, 1, 1, 1],
1 => [0, 0, 1, 0, 0, 1, 0],
2 => [1, 0, 1, 1, 1, 0, 1],
3 => [1, 0, 1, 1, 0, 1, 1],
4 => [0, 1, 1, 1, 0, 1, 0],
5 => [1, 1, 0, 1, 0, 1, 1],
6 => [1, 1, 0, 1, 1, 1, 1],
7 => [1, 0, 1, 0, 0, 1, 0],
8 => [1, 1, 1, 1, 1, 1, 1],
9 => [1, 1, 1, 1, 0, 1, 1],
];
$space = ' ';
$result = array_fill_keys(range(0, $s * 2 + 2), '');
foreach (array_map('intval', str_split($n)) as $key => $tmp) {
if (!isset($arr[$tmp])) continue;
foreach ($arr[$tmp] as $k => $v) {
[$line, $sign] = (function() use($k, $s) : array {
if ($k === 0) return [0, '-'];
if ($k === 1) return [1, '|'];
if ($k === 2) return [1, '|'];
if ($k === 3) return [$s + 1, '-'];
if ($k === 4) return [$s + 2, '|'];
if ($k === 5) return [$s + 2, '|'];
if ($k === 6) return [$s * 2 + 2, '-'];
return [0, '-'];
})();
$str = $v === 1 ? $sign : ' ';
if ($sign === '-') {
$result[$line] .= ' '.str_repeat($str, $s).' '.$space;
}
else if ($sign === '|') {
foreach (range($line, $line + $s - 1) as $i) {
$result[$i] .= $str;
if ($k === 2 || $k === 5) $result[$i] .= $space;
if ($k === 1 || $k === 4) $result[$i] .= str_repeat(' ', $s);
}
}
}
}
return implode(PHP_EOL, $result).PHP_EOL;
};
print_r($fn(2, 12345));
/*
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
*/
print_r($fn(3, 67890));
/*
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
*/
print_r($fn(0, 0));
# 0. reference table
number = [
[
" - ",
"| |",
" ",
"| |",
" - "
], # 0
[
" ",
" |",
" ",
" |",
" "
], # 1
[
" - ",
" |",
" - ",
"| ",
" - "
], # 2
[
" - ",
" |",
" - ",
" |",
" - "
], # 3
[
" ",
"| |",
" - ",
" |",
" "
], # 4
[
" - ",
"| ",
" - ",
" |",
" - "
], # 5
[
" - ",
"| ",
" - ",
"| |",
" - "
], # 6
[
" - ",
" |",
" ",
" |",
" "
], # 7
[
" - ",
"| |",
" - ",
"| |",
" - "
], # 8
[
" - ",
"| |",
" - ",
" |",
" - "
] # 9
]
# 1. 전역 변수 초기화
S, N = '', ''
X, Y, Z = 0, 0, 0
# 2. 입력된 사이즈에 따라 기본 배열의 크기를 확장하는 함수
def span(s, n):
result = [" "*X for i in range(Y)]
r = number[n]
di = 0
for i in range(5): # 숫자 표시의 기본 행 수 만큼 반복
result[i+di] = r[i][0] + r[i][1]*s + r[i][-1] # 사이즈(s)에 따라 열을 늘림
if (not (i+di == 0 or i+di == Y//2 or i+di == Y-1)): # 첫 행, 중간 행, 마지막 행의 경우 스킵
while (not ((i+di+1 == Y//2) or (i+di+1 == Y-1))): # 사이즈(s) 에 따라 행을 늘림
del(result[i+di+1])
result.insert(i+di+1,result[i+di])
di += 1
return result
# 3. 결과를 화면에 표시하는 함수
def display(l):
for i in range(Y):
for j in range(Z):
print(l[j][i], end=' ')
print('')
# 4. 입력, 처리, 출력
f = open("D:\\99.Temp\\exercise\\코딩도장\\input.txt", 'r')
while True:
line = f.readline()
if not line: # 더 이상 읽어오는 line이 없을 경우 종료
break
S, N = line.split(' ')
if S == '0': # "0 0" 읽어오는 경우 종료
break
N = N.strip('\n') # 개행 문자 제거
X, Y, Z = int(S)+2, int(S)*2+3, len(N) # X(숫자의 넓이) Y(숫자의 높이) Z(숫자의 개수)
output = [[" "*X for i in range(Y)] for j in range(Z)] # output 초기화
for i in range(Z):
n = span(int(S), int(N[i])) # 사이즈에 따를 숫자 배열 얻어오기
del(output[i])
output.insert(i, n) # output에 숫자 배열 추가
display(output)
f.close()
1.숫자별(0~9) 5행의 출력 정보 정의 ( 0:공백 1:- 2:좌측| 3:우측| 4:양쪽| )
top top ~ mid mid mid ~ bot bottom
1011011111 4333422344 001111101 1432333434 31011011011 => 10개 숫자 x 5행
2.위에 정의한 문자열 T 를 => 출력할 행문자열의 배열 R로 변환 (s 크기에 따라 열을 늘리며)
3.각 행별 출력할 문자에 대한 문자열을 rows 에서 가져와 완전한 행으로 병합해 출력
static void Main()
{
var args = Console.In.ReadToEnd().Split(' ', '\n');
for (int h, p, i = 0; i < args.Length; Console.WriteLine())
{
int s = args[i++][0] - 48; // 출력 크기 (정수 1 <= s < 10)
var n = args[i++]; // 출력 숫자 (문자열 "0" ~ "99999999")
var T = "10110111114333422344001111101143233343431011011011".Select(a => a - 48);
var R = T.Select(a =>" | |"[a] + new string(" - "[a],s) + " ||"[a]).ToArray();
for (h = 0, p = 0; h < 2 * s + 3; h++)
{
Console.WriteLine(string.Join(" ", n.Select(c => R[p * 10 + c - 48])));
p += (h + 1) % (s + 1) < 2 ? 1 : 0;
}
}
}
출력
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
거의 노가다수준의 코딩입니다. ㅠㅠ 너무 어렵습니다. 문자가 2개중 하나 출력되면 되니, binary code로 한번 더 도전해봐야 겠습니다. ㅠㅠ
s = 1
while s:
s, n = map(int,input("Enter 's n' :").split())
ptn_1 = ' '+'-'*s+' '
ptn_2 = ' '+' '*s+' '
ptn_3 = '|'+' '*s+'|'
ptn_4 = ' '+' '*s+'|'
ptn_5 = '|'+' '*s+' '
L1 = ptn_1 + ptn_2 + ptn_1*2 + ptn_2 + ptn_1*5
L2 = ptn_3 + ptn_4*3 + ptn_3 + ptn_5*2 + ptn_4 + ptn_3*2
L3 = ptn_2*2 + ptn_1*5 + ptn_2 + ptn_1*2
L4 = ptn_3 + ptn_4 + ptn_5 + ptn_4*3 + (ptn_3 + ptn_4)*2
L5 = ptn_1 + (ptn_2 + ptn_1*2)*3
for i in str(n):
print(L1[int(i)*(s+2):(int(i)+1)*(s+2)], end=' ')
print('')
for j in range(s):
for i in str(n):
print(L2[int(i)*(s+2):(int(i)+1)*(s+2)], end=' ')
print('')
for i in str(n):
print(L3[int(i)*(s+2):(int(i)+1)*(s+2)], end=' ')
print('')
for j in range(s):
for i in str(n):
print(L4[int(i)*(s+2):(int(i)+1)*(s+2)], end=' ')
print('')
for i in str(n):
print(L5[int(i)*(s+2):(int(i)+1)*(s+2)], end=' ')
print('')
자바로 구현하니 허벌 나게 길구먼유 ㅠㅠㅠ 이틀걸렸습니다...
객체는 메인포함 3개로 나누어서 제작 했습니다....
package lcd;
import java.util.Scanner;
public class LCD_Mass {
public String[][] getMass(int s) {
LCD_Mass lcd = new LCD_Mass();
Scanner sc = new Scanner(System.in);
String[][] arr = new String[2*s+1][s+2];
String blank = " ";
String under = "_";
String bar = "|";
String line = "\n";
String display = blank;
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
arr[i][j] = blank;
}
}//배열 초기화
for (int i = 1; i < s+1; i++) {
arr[0][i] = under;
}
display += blank + line;
for (int i = 0; i < s; i++) {
if (i == s-1) {
arr[i+1][0] = bar;
arr[i+1][s+1] = bar;
for (int j = 1; j <= s; j++) {
arr[s][j] = under;
}
}else {
arr[i+1][0] = bar;
arr[i+1][s+1] = bar;
}
}
for (int i = 0; i < s; i++) {
if (i == s-1) {
arr[2*s][0] = bar;
arr[2*s][s+1] = bar;
for (int j = 1; j <= s; j++) {
arr[2*s][j] = under;
}
}else {
arr[s+i+1][0] = bar;
arr[s+i+1][s+1] = bar;
}
}
return arr;
}
}
package lcd;
public class LCD_display {
LCD_Mass lcd = new LCD_Mass();
public void numDisplay(long num,int scale) {
String s = Long.toString(num);
String[][] copy = null;
int num2;
int k = s.length()-1;
copy = new String[2*scale+1][(scale+2)*(k+1)];
for (k = 0; k < s.length(); k++) {
num2 = Integer.parseInt(s.substring(k,k+1));
String arr[][] = lcd.getMass(scale);
switch (num2) {
case 1:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (j == arr[i].length-1) {
continue;
}else{arr[i][j] = " ";}
}
}
break;
case 2:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (j == 0 && i <= scale || j == arr[i].length-1 && i > scale) {
arr[i][j] = " ";
}
}
}
break;
case 3:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (j == 0) {
arr[i][j] = " ";
}
}
}
break;
case 4:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (i == 0 || j == 0 && i > scale
|| i == arr.length-1 && j != arr[i].length-1) {
arr[i][j] = " ";
}
}
}
break;
case 5:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (j == 0 && i > scale || j == arr[i].length-1 && i <= scale) {
arr[i][j] = " ";
}
}
}
break;
case 6:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (i == 0 || j == arr[i].length-1 && i <= scale) {
arr[i][j] = " ";
}
}
}
break;
case 7:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (j == arr[i].length-1||i==0) {
continue;
}else{arr[i][j] = " ";}
}
}
break;
case 8:
break;
case 9:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if ( j == 0 && i > scale ) {
arr[i][j] = " ";
}
}
}
break;
case 0:
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if ( i == scale) {
if (j == 0 || j == arr[i].length - 1) {
continue;
}
arr[i][j] = " ";
}
}
}
break;
default:
break;
}//switch
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
copy[i][j+(scale+2)*k] = arr[i][j];
}
}//배열 복사
// 8 8 8 8
//0,1,2,3 4,5,6,7 8,9,10,11 12,13,14,15
}//big for
for (int i = 0; i < copy.length; i++) {
for (int j = 0; j < copy[i].length; j++) {
System.out.print(copy[i][j]);
}
System.out.println();
}
}//메서드
}
package lcd;
import java.util.Scanner;
public class LCD_main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int s = 3;
long n = 5;
System.out.println("크기 입력");
s = sc.nextInt();
System.out.println("숫자 입력");
n = sc.nextLong();
LCD_display lcd = new LCD_display();
LCD_Mass mass = new LCD_Mass();
//mass.getMass(s);
lcd.numDisplay(n, s);
}
}
import re
INP = input("input : ")
INP_COMPILE = re.compile("\d+")
INP_LIST, RES, RES_LIST = INP_COMPILE.findall(INP), '', []
MAP, a, b, c, d, e, f, g = 'abcdefg', '1011011111', '1000111111', '1111100111', '0011111011', '1010001010', '1101111111', '1011011011'
COMP1, COMP2, COMP3 = ' ', '-', '|'
for m in MAP :
for n in range(0, len(INP_LIST[1])) :
RES += eval(str(m)+'['+INP_LIST[1][n]+']')
RES_LIST.append(RES)
RES = ''
def hor(o) :
typ = ''
for i in o :
typ += ' '+str('-'*int(INP_LIST[0])*int(i)).ljust(int(INP_LIST[0]))+' '
print(typ)
def ver(l1, l2) :
typ = ''
for w in range(0, len(l1)) :
typ += str('|'*int(l1[w])).ljust(1)+' '*int(INP_LIST[0])+str('|'*int(l2[w])).ljust(1)+' '
for dd in range(0, int(INP_LIST[0])) :
print(typ)
def lcd(re) :
hor(re[0])
ver(re[1], re[2])
hor(re[3])
ver(re[4], re[5])
hor(re[6])
lcd(RES_LIST)
결과
input : 4 28569
---- ---- ---- ---- ----
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
---- ---- ---- ---- ----
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
---- ---- ---- ---- ----
Javascript(ES6)...
`최소 사이즈인 1 일 때 각 숫자의 디자인 패턴을 미리 design 배열로 생성, 출력을 위해 한줄출력 함수 _print_singleline 함수와 전체 출력함수인 print_LCD 함수를 구현
최소 사이즈 1 일 때는 아래처럼 총 5 줄을 출력하면 됨
-
| |
-
| |
-
print_LCD 함수가 _print_singline 함수를 5번 호출하되, _print_singline 함수는 주어진 size 에 따라 가로 반복을 하며 같은 줄을 여러번 출력할 수 있도록 구현`;
class CustomLCD {
constructor(size = 1, num = 0) {
// 한계 설정 1 <= size < 10, 0 <= num <= 99999999
this.size = Math.max(1, Math.min(size, 9));
this.str_num = Math.max(0, Math.min(num, 99999999)).toString();
// 숫자 디자인 패턴
this.designs = [
' - | | | | - ', // 0
' | | ', // 1
' - | - | - ', // 2
' - | - | - ', // 3
' | | - | ', // 4
' - | - | - ', // 5
' - | - | | - ', // 6
' - | | ', // 7
' - | | - | | - ', // 8
' - | | - | - ', // 9
];
}
// 한줄 출력 함수, repeat_count 는 같은 줄을 몇번 반복할 것인가 결정
_print_singleline(row, repeat_count = 1) {
let output = '';
for(let str_n of this.str_num) {
let n = Number(str_n);
output += ' ';
output += this.designs[n][row * 3];
output += this.designs[n][row * 3 + 1].repeat(this.size);
output += this.designs[n][row * 3 + 2];
}
for(let i = 0; i < repeat_count; i++) {
console.log(output);
}
}
// 전체 출력함수
print_LCD() {
this._print_singleline(0);
this._print_singleline(1, this.size);
this._print_singleline(2);
this._print_singleline(3, this.size);
this._print_singleline(4);
}
}
new CustomLCD(2, 12345).print_LCD();
new CustomLCD(3, 67890).print_LCD();
Python 3...
class CustomLCD:
def __init__(self, size, num):
self.size = max(1, min(9, size))
self.str_num = str(max(0, min(99999999, num)))
self.designs = [
' - | | | | - ', # 0
' | | ', # 1
' - | - | - ', # 2
' - | - | - ', # 3
' | | - | ', # 4
' - | - | - ', # 5
' - | - | | - ', # 6
' - | | ', # 7
' - | | - | | - ', # 8
' - | | - | - ', # 9
]
# 지정한 row 에 해당하는 한줄 출력 함수, 그 한줄을 반복 출력할 수도 있음
def __print_single_line(self, row, repeat_count = 1):
output = ''
for str_n in self.str_num:
output += ' '
output += self.designs[int(str_n)][row * 3]
output += self.designs[int(str_n)][row * 3 + 1] * self.size
output += self.designs[int(str_n)][row * 3 + 2]
for i in range(repeat_count):
print(output)
# 전체 출력함수
def print_LCD(self):
self.__print_single_line(0)
self.__print_single_line(1, self.size)
self.__print_single_line(2)
self.__print_single_line(3, self.size)
self.__print_single_line(4)
CustomLCD(2, 12345).print_LCD()
CustomLCD(3, 67890).print_LCD()
Python으로 작성한 코드입니다. 먼저 필요한 함수를 정의한 다음에 사용하였습니다.
##### 각 숫자에 맞춰 2D 리스트의 요소 수정 ####
## 0
def zero_LCD(s,c,M): ## s, initial_col , Matrix
for i in range(1,s+1):
M[0][c+i] = M[2*s+2][c+i] = '-'
M[i][c] = M[i][c+s+1] = M[i+s+1][c] = M[i+s+1][c+s+1] = '|'
return M
## 1
def one_LCD(s,c,M):
for i in range(1,s+1):
M[i][c+s+1] = M[s+i+1][c+s+1] ='|'
return M
## 2
def two_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = M[s+1][c+i] = M[2*s+2][c+i] = '-'
M[i][c+s+1] = M[i+s+1][c] = '|'
return M
## 3
def three_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = M[s+1][c+i] = M[2*s+2][c+i] = '-'
M[i][c+s+1] = M[i+s+1][c+s+1] = '|'
return M
## 4
def four_LCD(s,c,M):
for i in range(1,s+1):
M[s+1][c+i]='-'
M[i][c] = M[i][c+s+1] = M[i+s+1][c+s+1] = '|'
return M
## 5
def five_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = M[s+1][c+i] = M[2*s+2][c+i] = '-'
M[i][c] = M[i+s+1][c+s+1] = '|'
return M
## 6
def six_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = M[s+1][c+i] = M[2*s+2][c+i] = '-'
M[i][c] = M[i+s+1][c] = M[i+s+1][c+s+1] = '|'
return M
## 7
def seven_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = '-'
M[i][c+s+1] = M[i+s+1][c+s+1] = '|'
return M
## 8
def eight_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = M[s+1][c+i] = M[2*s+2][c+i] = '-'
M[i][c] = M[i][c+s+1] = M[i+s+1][c] = M[i+s+1][c+s+1] = '|'
return M
## 9
def nine_LCD(s,c,M):
for i in range(1,s+1):
M[0][c+i] = M[s+1][c+i] = M[2*s+2][c+i] = '-'
M[i][c] = M[i][c+s+1] = M[i+s+1][c+s+1] = '|'
return M
## 전체 숫자 함수
def num_LCD(n,s,c,M):
if n==0: zero_LCD(s,c,M)
elif n==1: one_LCD(s,c,M)
elif n==2: two_LCD(s,c,M)
elif n==3: three_LCD(s,c,M)
elif n==4: four_LCD(s,c,M)
elif n==5: five_LCD(s,c,M)
elif n==6: six_LCD(s,c,M)
elif n==7: seven_LCD(s,c,M)
elif n==8: eight_LCD(s,c,M)
elif n==9: nine_LCD(s,c,M)
else: print('잘못된 숫자 입력')
### s와 숫자로 구성된 문자열을 입력하면 디지털 숫자를 한줄 출력 ###
def LCD_Output(s_in,N_in): ## 문자열도 받는다
s = int(s_in)
N=[]
for i in range(len(N_in)):
N.append(int(N_in[i]))
M=[] ## 2D list
## Initializing M ##
for _ in range(2*s+3):
line = []
for _ in range((s+2)*len(N)):
line.append(' ')
M.append(line)
## Calculating M ##
for i in range (len(N)):
num_LCD(N[i],s,i*(s+2),M)
## print(M) ##
for i in range(2*s+3):
for j in range((s+2)*len(N)):
print(M[i][j],end='')
print()
## 전체 시행 ##
if __name__ == '__main__':
line = ''
L=[]
while True:
line = input()
if line == '0 0':
break
L.append(line)
for i in range(len(L)):
s_in, N_in = L[i].split()
LCD_Output(s_in,N_in)
def lcd_disp(size, num_str):
_map = ['1011010111',
'1000111111',
'1111100111',
'0011111011',
'1010001010',
'1101111111',
'1011011010']
def _horizon(key):
prt = [' ', '-']
for x in num_str:
print (' {} '.format(prt[int(_map[key][int(x)])] * size), end=' ')
print('')
def _vertical(key1, key2):
prt = [' ', '|']
for i in range(size):
for x in num_str:
print ('{}{}{}'.format(prt[int(_map[key1][int(x)])]
,' ' * size
,prt[int(_map[key2][int(x)])]),
end=' ')
print('')
_horizon(0)
_vertical(1, 2)
_horizon(3)
_vertical(4, 5)
_horizon(6)
lcd_disp(2, '02852')
lcd_disp(3, '12345')
s=int(input("숫자의 크기(1~9)를 입력하십시오: "))
n=input("양의 정수 n을 입력하십시오: ")
nlst=list(map(int,n))
def zero(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==2*s+2:
table[i][k]="-"
else:
table[i][0],table[i][-1]='|','|'
return table
def one(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
if i!=0 and i!=s+1 and i!=(2*s+2):
table[i][-1]='|'
return table
def two(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==s+1 or i==(2*s+2):
table[i][k]="-"
elif i>0 and i<s+1:
table[i][-1]='|'
else:
table[i][0]='|'
return table
def three(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==s+1 or i==(2*s+2):
table[i][k]="-"
else:
table[i][-1]='|'
return table
def four(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==s+1:
table[i][k]="-"
elif i>0 and i<s+1:
table[i][-1],table[i][0]='|','|'
elif i!=0 and i!=2*s+2:
table[i][-1]='|'
return table
def five(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==s+1 or i==(2*s+2):
table[i][k]="-"
elif i>0 and i<s+1:
table[i][0]='|'
else:
table[i][-1]='|'
return table
def six(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==s+1 or i==(2*s+2):
table[i][k]="-"
elif i>0 and i<s+1:
table[i][0]='|'
else:
table[i][-1],table[i][0]='|','|'
return table
def seven(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i!=0 and i!=s+1 and i!=(2*s+2):
table[i][-1]='|'
elif i==0:
table[i][k]="-"
return table
def eight(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==s+1 or i==(2*s+2):
table[i][k]="-"
elif i>0 and i<s+1:
table[i][-1],table[i][0]='|','|'
else:
table[i][-1],table[i][0]='|','|'
return table
def nine(s):
table=eval(repr([[" "]*(s+2)]*(2*s+3)))
for i in range(2*s+3):
for k in range(1,s+1):
if i==0 or i==s+1 or i==(2*s+2):
table[i][k]="-"
elif i>0 and i<s+1:
table[i][-1],table[i][0]='|','|'
else:
table[i][-1]='|'
return table
elst=[]
for num in nlst:
if num==1: elst.append(one(s))
elif num==2: elst.append(two(s))
elif num==3: elst.append(three(s))
elif num==4: elst.append(four(s))
elif num==5: elst.append(five(s))
elif num==6: elst.append(six(s))
elif num==7: elst.append(seven(s))
elif num==8: elst.append(eight(s))
elif num==9: elst.append(nine(s))
else: elst.append(zero(s))
for i in range(2*s + 3):
for j in range(len(n)):
print("".join(elst[j][i]),end=" ")
print()
실력이 없어서 노가다를 엄청해서 매우 깁니다. 나중에 좀 늘고나서 짧게 고칠 수 있으면 좋겠습니다.
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
/*
LCD Display
한 친구가 방금 새 컴퓨터를 샀다. 그 친구가 지금까지 샀던 가장 강력한 컴퓨터는 공학용 전자 계산기였다.
그런데 그 친구는 새 컴퓨터의 모니터보다 공학용 계산기에 있는 LCD 디스플레이가 더 좋다며 크게 실망하고 말았다.
그 친구를 만족시킬 수 있도록 숫자를 LCD 디스플레이 방식으로 출력하는 프로그램을 만들어보자.
입력
입력 파일은 여러 줄로 구성되며 표시될 각각의 숫자마다 한 줄씩 입력된다.
각 줄에는 s와 n이라는 두개의 정수가 들어있으며 n은 출력될 숫자( 0<= n <= 99,999,999 ),
s는 숫자를 표시하는 크기( 1<= s < 10 )를 의미한다.
0 이 두 개 입력된 줄이 있으면 입력이 종료되며 그 줄은 처리되지 않는다.
출력
입력 파일에서 지정한 숫자를 수평 방향은 '-' 기호를, 수직 방향은 '|'를 이용해서 LCD 디스플레이 형태로 출력한다.
각 숫자는 정확하게 s+2개의 열, 2s+3개의 행으로 구성된다.
마지막 숫자를 포함한 모든 숫자를 이루는 공백을 스페이스로 채워야 한다.
두 개의 숫자 사이에는 정확하게 한 열의 공백이 있어야 한다.
각 숫자 다음에는 빈 줄을 한 줄 출력한다. 밑에 있는 출력 예에 각 숫자를 출력하는 방식이 나와있다.
입력 예
2 12345
3 67890
0 0
출력 예
-- -- --
| | | | | |
| | | | | |
-- -- -- --
| | | | |
| | | | |
-- -- --
--- --- --- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- ---
| | | | | | | |
| | | | | | | |
| | | | | | | |
--- --- --- ---
*/
void gotoxy(int x, int y){
COORD pos = { x,y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
COORD getXY() {
COORD Cur;
CONSOLE_SCREEN_BUFFER_INFO a;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &a);
Cur.X = a.dwCursorPosition.X;
Cur.Y = a.dwCursorPosition.Y;
return Cur;
}
void Func(int s, string str) {
int x = s * 2 + 3;
int y = s + 2;
char **arr = new char*[x];
for (int i = 0; i < x; i++)
arr[i] = new char[y];
int m = x / 2;
int count = 0;
COORD c, h;
for (int i = 0; i < str.length(); i++) {
for (int i = 0; i < x; i++)
for (int j = 0; j < y; j++)
arr[i][j] = ' ';
if (str[i] == '0') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (i == m) { continue; }
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (j == 0 || j == y - 1) { arr[i][j] = '|'; }
}
}
}
}
else if (str[i] == '1') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) { continue; }
else {
if (j == 0) { arr[i][j] = '|'; }
}
}
}
}
else if (str[i] == '2') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (i < m) { if (j == y - 1) { arr[i][j] = '|'; } }
else { if (j == 0) { arr[i][j] = '|'; } }
}
}
}
}
else if (str[i] == '3') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (j == y - 1) { arr[i][j] = '|'; }
}
}
}
}
else if (str[i] == '4') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (i == 0 || i == x - 1) { continue; }
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (i < m) { if (j == 0 || j == y - 1) { arr[i][j] = '|'; } }
else { if (j == y - 1) { arr[i][j] = '|'; } }
}
}
}
}
else if (str[i] == '5') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (i < m) { if (j == 0) { arr[i][j] = '|'; } }
else { if (j == y - 1) { arr[i][j] = '|'; } }
}
}
}
}
else if (str[i] == '6') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (i < m) { if (j == 0) { arr[i][j] = '|'; } }
else { if (j == 0 || j == y - 1)arr[i][j] = '|'; }
}
}
}
}
else if (str[i] == '7') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (i == m) { continue; }
if (i == x - 1) { continue; }
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (j == y - 1) { arr[i][j] = '|'; }
}
}
}
}
else if (str[i] == '8') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (j == 0 || j == y - 1) { arr[i][j] = '|'; }
}
}
}
}
else if (str[i] == '9') {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 || i == m || i == x - 1) {
if (j == 0 || j == y - 1) { continue; }
arr[i][j] = '-';
}
else {
if (i < m) { if (j == 0 || j == y - 1) { arr[i][j] = '|'; } }
else { if (j == y - 1) { arr[i][j] = '|'; } }
}
}
}
}
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
if (i == 0 && j == y - 1) { c = getXY(); }
if (j == 0) { h = getXY(); }
cout << arr[i][j];
}
if (count > 0) { gotoxy(h.X, h.Y + 1); }
else { cout << endl; }
}
if (i == str.length() - 1) { break; }
if (str[i] == '1') { gotoxy(c.X-1, c.Y); }
else { gotoxy(c.X + 2, c.Y); }
count++;
}
for (int i = 0; i < x; i++)
delete[] arr[i];
delete[] arr;
}
int main() {
int s;
string n;
int m;
while (1) {
cout << "출력될 숫자, 숫자를표시할크기(0 0 입력시 종료):";
cin >> n >> s;
m = stoi(n);
if (m == 0 && s == 0) { break; }
if (s == 0) { cout << "숫자를 표시할 크기는 1이상 10미만이어야 합니다" << endl; continue; }
if (m < 0 || m > 99999999) { cout << "출력 될숫자는 0이상 99999999이하 여야 합니다" << endl; continue; }
Func(s, n);
cout << endl;
}
}
def lcd(inp):
masks = ('02356789', '045689', '01234789', '2345689', '0268', '013456789', '0235689')
for s, digits in inp:
result = []
h = lambda x: ' '.join(' ' + ('-' if d in masks[x] else ' ') * s + ' ' for d in digits)
v = lambda x: ' '.join(('|' if d in masks[x] else ' ') + ' ' * s + ('|' if d in masks[x+1] else ' ') for d in digits)
result.append(h(0))
result += [v(1)] * s
result.append(h(3))
result += [v(4)] * s
result.append(h(6))
print('\n'.join(result))
if __name__ == '__main__':
s = 1
digits = '1'
inp = []
while s != 0:
s, digits = input('입력: ').split()
s = int(s)
if s != 0:
inp.append((s, digits))
lcd(inp)
import UIKit
var str = "Hello, playground"
func printLCD(S:Int,N:Int) {
let width:Int = S + 2
let height:Int = S * 2 + 3
let numberStrArr = Array("\(N)")
print("width:\(width)")
for i in 0..<height {
var lineStr:String = ""
for k in 0..<numberStrArr.count {
for j in 0..<width {
lineStr = lineStr + getCharAtIndex(S: S, xIndex: j, yIndex: i, number: Int(String(numberStrArr[k]))!)
}
}
print("\(lineStr)")
}
}
func getCharAtIndex(S:Int,xIndex:Int,yIndex:Int,number:Int) -> String {
var returnCahr:String = "e"
let width:Int = S + 2
let height:Int = S * 2 + 3
switch number {
case 0:
if yIndex == 0 || yIndex == height - 1 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex == height/2 {
returnCahr = " "
}
else {
if xIndex == 0 || xIndex == width - 1{
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 1:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
returnCahr = " "
}
else {
if xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 2:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex > 0 && height/2 > yIndex{
if xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
else {
if xIndex == 0 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 3:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else {
if xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 4:
if yIndex == 0 || yIndex == height - 1 {
returnCahr = " "
}
else if yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex > 0 && height/2 > yIndex{
if xIndex == 0 || xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
else {
if xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 5:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex > 0 && height/2 > yIndex{
if xIndex == 0 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
else {
if xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 6:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex > 0 && height/2 > yIndex{
if xIndex == 0 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
else {
if xIndex == 0 || xIndex == width - 1{
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 7:
if yIndex == 0 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex == height - 1 || yIndex == height/2 {
returnCahr = " "
}
else {
if xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 8:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else {
if xIndex == 0 || xIndex == width - 1{
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
case 9:
if yIndex == 0 || yIndex == height - 1 || yIndex == height/2 {
if xIndex == 0 || xIndex == width - 1 {
returnCahr = " "
}
else {
returnCahr = "-"
}
}
else if yIndex > 0 && height/2 > yIndex{
if xIndex == 0 || xIndex == width - 1 {
returnCahr = "|"
}
else {
returnCahr = " "
}
}
else {
if xIndex == width - 1{
returnCahr = "|"
}
else {
returnCahr = " "
}
}
break
default:
break
}
return returnCahr
}
printLCD(S: 2, N: 67890)
def lcd_disp(size, num_str):
# - 0
# | | 1 2
# _ 3
# | | 4 5
# _ 6
_map = [
'1011010111',
'1000111111',
'1111100111',
'0011111011',
'1010001010',
'1101111111',
'1011011010'
]
def _horizon(key):
prt = [' ', '-']
for x in num_str:
print (' {} '.format(prt[int(_map[key][int(x)])] * size), end=' ')
print('')
def _vertical(key1, key2):
prt = [' ', '|']
for i in range(size):
for x in num_str:
print ('{}{}{}'.format(prt[int(_map[key1][int(x)])]
,' ' * size
,prt[int(_map[key2][int(x)])]),
end=' ')
print('')
_horizon(0)
_vertical(1, 2)
_horizon(3)
_vertical(4, 5)
_horizon(6)
lcd_disp(2, '12345') lcd_disp(3, '67890')
class Digit:
def __init__(self,i,l):
self.name = i # face name
self.geometry = l # geometry
self.size = 3 # default size
self.face = ""
self.shape = ["*","|","|","_","|","|","_","_"]
def getFace(self,sz):
self.size = sz
f = []
for r in range(0, sz*2+3):
f.append(["0" for c in range(0, sz+2)])
for j in range(1,sz+1):
f[0][j] = "6"
for i in range(1,sz+1):
f[i][0] = "5"
f[i][sz+1] = "1"
for j in range(1,sz+1):
f[sz+1][j] = "7"
for i in range(sz+2,sz+2+sz):
f[i][0] = "4"
f[i][sz+1] = "2"
for j in range(1,sz+1):
f[sz*2+2][j] = "3"
for i in range(0,sz*2+3):
for j in range(0,sz+2):
if f[i][j] in "0":
f[i][j] = " "
else:
index = 0
for k in self.geometry:
if f[i][j] in str(k):
f[i][j] = self.shape[k]
index = 1
if index==0:
f[i][j] = " "
for i in range(0,sz*2+3):
for j in range(0,sz+2):
self.face += f[i][j]
self.face += "\n"
class displayNumber:
def __init__(self):
pass
self.num = []
def createDigit(self):
self.num.append(Digit(0,[1,2,3,4,5,6]))
self.num.append(Digit(1,[1,2]))
self.num.append(Digit(2,[1,3,4,6,7]))
self.num.append(Digit(3,[1,2,3,6,7]))
self.num.append(Digit(4,[1,2,5,7]))
self.num.append(Digit(5,[2,3,5,6,7]))
self.num.append(Digit(6,[2,3,4,5,6,7]))
self.num.append(Digit(7,[1,2,6]))
self.num.append(Digit(8,[1,2,3,4,5,6,7]))
self.num.append(Digit(9,[1,2,5,6,7]))
def writeDigit(self,sz,nnn):
line = str(nnn)
for n in line:
self.num[int(n)].getFace(sz)
l = []
for n in line:
l.append(self.num[int(n)].face.split("\n"))
for i,n in enumerate(l[0]):
for j,m in enumerate(line):
print(l[j][i],end=" ")
print("")
#print(l)
a = displayNumber()
a.createDigit()
a.writeDigit(2,123) # (size,number)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Number {
int size;
int num;
public:
Number(const int size, const int num) {
this->size=size;
this->num=num;
}
void getNum(const int count, const int onenum) const {
switch (onenum) {
case 1 :
if(ex1(count)) {
loop(size+2, ' ');
}
else {
loop(size+1, ' ');
loop(1, '|');
}
break;
case 2 :
if(ex1(count)) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(ex2(count)) {
loop(size+1, ' ');
loop(1, '|');
}
else if(ex3(count)) {
loop(1, '|');
loop(size+1, ' ');
}
break;
case 3:
if(ex1(count)) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else {
loop(size+1, ' ');
loop(1, '|');
}
break;
case 4:
if(count==0 || count==2*size+2) {
loop(size+2, ' ');
}
else if(count==size+1) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(ex2(count)) {
loop(1, '|');
loop(size, ' ');
loop(1, '|');
}
else if(ex3(count)) {
loop(size+1, ' ');
loop(1, '|');
}
break;
case 5:
if (ex1(count)) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(ex2(count)) {
loop(1, '|');
loop(size+1, ' ');
}
else if(ex3(count)) {
loop(size+1, ' ');
loop(1, '|');
}
break;
case 6:
if(ex1(count)) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(ex2(count)) {
loop(1, '|');
loop(size+1, ' ');
}
else if(ex3(count)) {
loop(1, '|');
loop(size, ' ');
loop(1, '|');
}
break;
case 7:
if(count==0) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(count == size+1 || count == 2*size+2) {
loop(size+2, ' ');
}
else if(ex2(count) || ex3(count)) {
loop(size+1,' ');
loop(1, '|');
}
break;
case 8:
if(ex1(count)) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else {
loop(1, '|');
loop(size, ' ');
loop(1, '|');
}
break;
case 9:
if(ex1(count)) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(ex2(count)) {
loop(1, '|');
loop(size, ' ');
loop(1, '|');
}
else if(ex3(count)) {
loop(size+1, ' ');
loop(1, '|');
}
break;
case 0:
if(count==0 || count==2*size+2) {
loop(1, ' ');
loop(size, '-');
loop(1, ' ');
}
else if(ex2(count) || ex3(count)) {
loop(1, '|');
loop(size, ' ');
loop(1, '|');
}
else if(count == size+1) {
loop(size+2, ' ');
}
break;
default:
break;
}
}
void loop(int s, char c) const {
for(int i =0;i<s;i++) {
cout << c;
}
}
bool ex1(int count) const {
if(count==0 || count==size+1 || count==2*size+2) {
return true;
}
else
return false;
}
bool ex2(int count) const {
if(count<size+1 && count >0) {
return true;
}
else
return false;
}
bool ex3(int count) const {
if(count>size+1 && count <2*size+2) {
return true;
}
else
return false;
}
void print() const {
int _num=num;
vector<int> arrnum;
while(_num!=0) {
arrnum.push_back(_num%10);
_num /= 10;
}
reverse(arrnum.begin(), arrnum.end());
for(int i=0;i<2*size+3;i++) {
for(int j=0;j<arrnum.size();j++) {
getNum(i, arrnum[j]);
cout << " ";
}
cout << endl;
}
}
};
int main() {
int size=-1;
int num;
vector<Number> group;
while (true) {
cin >> size >> num;
if(num>=100000000 || num<0 || size==0) {
break;
}
group.push_back(Number(size, num));
}
for(int i =0;i<group.size();i++) {
group[i].print();
if (i != group.size()) {
cout << "\n\n";
}
}
return 0;
}
def prtOneDigit(s, n): #s: size for digit, n : digit to be displayed.
nn = ' ' * (s + 2) #' '
iI = 'I' + ' ' * (s+1) #'l '
fI = ' '* (s+1) + 'I' #' l'
ifI = 'I' + ' ' * s + 'I' #'I I'
hh = ' ' + '-' * s + ' ' #' --- '
ws = ' '
result = []
if n == 1:
result = [nn] + [fI] * s +[nn] + [fI] * s + [nn]
elif n == 2:
result = [hh] + [fI] * s + [hh] + [iI] * s + [hh]
elif n == 3:
result = [hh] + [fI] * s + [hh] + [fI] * s + [hh]
elif n == 4:
result = [nn] + [ifI] * s + [hh] + [fI] * s + [nn]
elif n == 5:
result = [hh] + [iI] * s + [hh] + [fI] * s + [hh]
elif n == 6:
result = [hh] + [iI] * s + [hh] + [ifI] * s + [hh]
elif n == 7:
result = [hh] + [fI] * s + [nn] + [fI] * s + [nn]
elif n == 8:
result = [hh] + [ifI] * s + [hh] + [ifI] * s + [hh]
elif n == 9:
result = [hh] + [ifI] * s + [hh] + [fI] * s + [hh]
elif n == 0:
result = [hh] + [ifI] * s + [nn] + [ifI] * s + [hh]
return result
def prtMultDigit(s, ns):
result = []
for n in str(ns):
result.append((prtOneDigit(s, int(n))))
return ["".join(row[i]+' ' for row in result) for i in range(len(result[0]))]
y = prtMultDigit(3, 123456)
for c in y:
print(c)
노가다...
def LCD(n,num): #n은 크기 , num은 표시할 숫자
num = [int(_) for _ in str(num)]
one = ['┏'+'━'*n+'┓','┓',' '+'━'*n+'┓',' '+'━'*n+'┓','┳'+' '*n+'┳','┏'+'━'*n+' ','┏'+'━'*n+' ','┏'+'━'*n+'┓','┏'+'━'*n+'┓','┏'+'━'*n+'┓']
two = ['┃'+' '*n+'┃','┃',' '*(n+1)+'┃',' '*(n+1)+'┃','┃'+' '*n+'┃','┃'+' '*(n+1),'┃'+' '*(n+1),' '*(n+1)+'┃','┃'+' '*n+'┃','┃'+' '*n+'┃']
three=['┃'+' '*n+'┃','┃','┏'+'━'*n+'┛',' '+'━'*n+'┫','┗'+'━'*n+'┫','┗'+'━'*n+'┓','┣'+'━'*n+'┓',' '+' '*n+'┃','┣'+'━'*n+'┫','┗'+'━'*n+'┫']
four =['┃'+' '*n+'┃','┃','┃'+' '*(n+1),' '*(n+1)+'┃',' '*(n+1)+'┃',' '*(n+1)+'┃','┃'+' '*n+'┃',' '*(n+1)+'┃','┃'+' '*n+'┃',' '*(n+1)+'┃']
five =['┗'+'━'*n+'┛','┻','┗'+'━'*n+' ',' '+'━'*n+'┛',' '*(n+1)+'┻',' '+'━'*n+'┛','┗'+'━'*n+'┛',' '*(n+1)+'┻','┗'+'━'*n+'┛',' '*(n+1)+'┻']
line = [one,two,three,four,five]
e = ''
for i in range(5):
if i==1 or i==3:
for _ in range(n):
for j in num: e+= f' {line[i][j]}'
e+='\n'
else :
for j in num: e+=f' {line[i][j]}'
e += '\n'
return e
print(LCD(2,1234567890))
#크기 s이면 숫자 하나당 가로=2+s칸, 세로=3+2s칸, 숫장 사이 띄어쓰기 한 칸 고정
#1,2,3,4,5,6,7,8,9,0의 각 행에 해당하는 draw 방식을 def해서 draw 클래스에 설정해두기-> s기준으로 작성
class draw():
def __init__(self,s):
self.num_size = s
self.templist = [] #인스턴스 변수로 설정
def ppp(self):
self.templist.append(' ')
for i in range(self.num_size):
self.templist.append('-')
self.templist.append(' ')
def vss(self):
self.templist.append('|')
for i in range(self.num_size+1):
self.templist.append(' ')
def vsv(self):
self.templist.append('|')
for i in range(self.num_size):
self.templist.append(' ')
self.templist.append('|')
def ssv(self):
for i in range(self.num_size+1):
self.templist.append(' ')
self.templist.append('|')
def sss(self):
for i in range(self.num_size+2):
self.templist.append(' ')
# input 받기
initlist = []
print('s와 n을 입력해주십시오')
while True:
inputstr = input('=>')
initlist.extend(list(map(int,inputstr.split())))
if inputstr.split()==['0','0']:
break
#print(initlist)
#n을 미리 배열해놓고 맨 윗줄부터 0번째 행, s+1번째 행, 2+2s번째 행을 기준으로 나눠서 draw의 각 모듈들을 배열 후 작성. n 하나가 모두 작성되면 print하고 다음 n 덮어서 새로 작성.
for k in range(len(initlist)):
if initlist[2*k]==0 and initlist[2*k+1]==0:
break
s=initlist[2*k]
n=initlist[2*k+1]
n_list = list(str(n))
num_n = len(n_list)
draw1 = draw(s)
for i in range(3+2*s):
if i == 0:
for j in range(num_n):
if int(n_list[j]) in [1,4]:
draw1.sss()
draw1.templist.append(' ')
else:
draw1.ppp()
draw1.templist.append(' ')
draw1.templist.append('\n')
elif i == s+1:
for j in range(num_n):
if int(n_list[j]) in [0,1,7]:
draw1.sss()
draw1.templist.append(' ')
else:
draw1.ppp()
draw1.templist.append(' ')
draw1.templist.append('\n')
elif i == 2+2*s:
for j in range(num_n):
if int(n_list[j]) in [1,4,7]:
draw1.sss()
draw1.templist.append(' ')
else:
draw1.ppp()
draw1.templist.append(' ')
draw1.templist.append('\n')
elif i in range(1,s+1):
for j in range(num_n):
if int(n_list[j]) in [1,2,3,7]:
draw1.ssv()
draw1.templist.append(' ')
elif int(n_list[j]) in [4,8,9,0]:
draw1.vsv()
draw1.templist.append(' ')
else:
draw1.vss()
draw1.templist.append(' ')
draw1.templist.append('\n')
elif i in range(s+2,2+2*s):
for j in range(num_n):
if int(n_list[j]) in [1,3,4,5,7,9]:
draw1.ssv()
draw1.templist.append(' ')
elif int(n_list[j]) in [6,8,0]:
draw1.vsv()
draw1.templist.append(' ')
else:
draw1.vss()
draw1.templist.append(' ')
draw1.templist.append('\n')
draw1.templist.append('\n')
finalstr = ''.join(draw1.templist)
print(finalstr)
# num=list(map(int, input().split()))
size, num = None,None #2
first_row = ""
middle_row1 = ""
real_middle = ""
middle_row2 = ""
last_row = ""
while(size, num) != ('0', '0') :
size, num = input().split()
size = int(size) #2134
lcd_col = " "+ "-" * size + " " #' -'
lcd_row_left = "|" + " " * size + " " # '| '
lcd_row_right = " " + " " * size + "|" # ' |'
lcd_row = "|" + " " * size + "|" # '| |'
empty_row = " " + " "* size + " "
global first_row ,middle_row1 ,real_middle ,middle_row2 ,last_row
for i in num :
if i == '1':
first_row += empty_row + " "
middle_row1 += lcd_row_right + " "
real_middle += empty_row + " "
middle_row2 += lcd_row_right + " "
last_row += empty_row + " "
elif i == '2':
first_row += lcd_col + " "
middle_row1 += lcd_row_right + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row_left + " "
last_row += lcd_col + " "
elif i == '3':
first_row += lcd_col + " "
middle_row1 += lcd_row_right + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row_right + " "
last_row += lcd_col + " "
elif i == '4':
first_row += empty_row + " "
middle_row1 += lcd_row + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row_right + " "
last_row += empty_row + " "
elif i == '5':
first_row += lcd_col + " "
middle_row1 += lcd_row_left + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row_right + " "
last_row += lcd_col + " "
elif i == '6':
first_row += lcd_col + " "
middle_row1 += lcd_row_left + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row + " "
last_row += lcd_col + " "
elif i == '7':
first_row += lcd_col + " "
middle_row1 += lcd_row + " "
real_middle += empty_row + " "
middle_row2 += lcd_row_right + " "
last_row += empty_row + " "
elif i == '8':
first_row += lcd_col + " "
middle_row1 += lcd_row + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row + " "
last_row += lcd_col + " "
elif i == '9':
first_row += lcd_col + " "
middle_row1 += lcd_row + " "
real_middle += lcd_col + " "
middle_row2 += lcd_row_right + " "
last_row += empty_row + " "
elif i == '0':
first_row += lcd_col + " "
middle_row1 += lcd_row + " "
real_middle += empty_row + " "
middle_row2 += lcd_row + " "
last_row += lcd_col + " "
print(first_row)
for i in range(size):
print(middle_row1)
print(real_middle)
for i in range(size):
print(middle_row2)
print(last_row)
first_row = ""
middle_row1 = ""
real_middle = ""
middle_row2 = ""
last_row = ""
def gen_space(s):
result = []
for i in range(2*s+3):
temp_row = []
for j in range(s+2):
temp_row.append(' ')
result.append(temp_row)
return result
def print_result(num, _list):
# num을 구성하는 영역을 나눈다. 위, 좌측부터 차례로 _1, _2, _3, _4, _5, _6, _7
if num == 1 : activate_list = ["_3", "_6"]
elif num == 2 : activate_list = ["_1", "_3", "_4", "_5", "_7"]
elif num == 3 : activate_list = ["_1", "_3", "_4", "_6", "_7"]
elif num == 4 : activate_list = ["_2", "_3", "_4", "_6"]
elif num == 5 : activate_list = ["_1", "_2", "_4", "_6", "_7"]
elif num == 6 : activate_list = ["_1", "_2", "_4", "_5", "_6", "_7"]
elif num == 7 : activate_list = ["_1", "_3", "_6"]
elif num == 8 : activate_list = ["_1", "_2", "_3", "_4", "_5", "_6", "_7"]
elif num == 9 : activate_list = ["_1", "_2", "_3", "_4", "_6", "_7"]
elif num == 0 : activate_list = ["_1", "_2", "_3", "_5", "_6", "_7"]
for member in activate_list:
if member == "_1" :
for i in range(1, len(_list[0])-1):
_list[0][i] = '-'
elif member == "_2" :
for i in range(1, len(_list[0])-1):
_list[i][0] = "|"
elif member == "_3" :
for i in range(1, len(_list[0])-1):
_list[i][-1] = "|"
elif member == "_4" :
for i in range(1, len(_list[0])-1):
_list[len(_list[0])-1][i] = '-'
elif member == "_5" :
for i in range(len(_list[0]), 2*len(_list[0])-2):
_list[i][0] = "|"
elif member == "_6" :
for i in range(len(_list[0]), 2*len(_list[0])-2):
_list[i][-1] = "|"
elif member == "_7" :
for i in range(1, len(_list[0])-1):
_list[-1][i] = '-'
return _list
if __name__ == '__main__' :
input_str = input('input - size numbers: ')
_size = int(input_str.split(" ")[0])
_numbers = input_str.split(" ")[1]
result_array = []
for member in _numbers:
result_array.append(print_result(int(member), gen_space(_size)))
for i in range(len(result_array[0])):
for j in range(len(_numbers)):
if j == len(_numbers)-1:
print(''.join(result_array[j][i]), end='\n')
else:
print(''.join(result_array[j][i]), end=' ')
def fun (b):
result=[[],[],[],[],[]]
n = int(b[0])
arr = list(map(int,b[2:]))
for a in arr:
if a==1:
result[0].append(' '+" "*n+' ')
result[1].append(' '*(n+1)+'|')
result[2].append(' '+" "*n+' ')
result[3].append(' '*(n+1)+'|')
result[4].append(' '+" "*n+' ')
elif a==2:
result[0].append(' '+"-"*n+' ')
result[1].append(' '*(n+1)+'|')
result[2].append(' '+"-"*n+' ')
result[3].append('|'+' '*(n+1))
result[4].append(' '+"-"*n+' ')
elif a==3:
result[0].append(' '+"-"*n+' ')
result[1].append(' '*(n+1)+'|')
result[2].append(' '+"-"*n+' ')
result[3].append(' '*(n+1)+'|')
result[4].append(' '+"-"*n+' ')
elif a==4:
result[0].append(' '+" "*n+' ')
result[1].append('|'+' '*n+'|')
result[2].append(' '+"-"*n+' ')
result[3].append(' '*(n+1)+'|')
result[4].append(' '+" "*n+' ')
elif a==5:
result[0].append(' '+"-"*n+' ')
result[1].append('|'+' '*(n+1))
result[2].append(' '+"-"*n+' ')
result[3].append(' '*(n+1)+'|')
result[4].append(' '+"-"*n+' ')
elif a==6:
result[0].append(' '+"-"*n+' ')
result[1].append('|'+' '*(n+1))
result[2].append(' '+"-"*n+' ')
result[3].append('|'+' '*n+'|')
result[4].append(' '+"-"*n+' ')
elif a==7:
result[0].append(' '+"-"*n+' ')
result[1].append(' '*(n+1)+'|')
result[2].append(' '+" "*n+' ')
result[3].append(' '*(n+1)+'|')
result[4].append(' '+" "*n+' ')
elif a==8:
result[0].append(' '+"-"*n+' ')
result[1].append('|'+' '*n+'|')
result[2].append(' '+"-"*n+' ')
result[3].append('|'+' '*n+'|')
result[4].append(' '+"-"*n+' ')
elif a==9:
result[0].append(' '+"-"*n+' ')
result[1].append('|'+' '*n+'|')
result[2].append(' '+"-"*n+' ')
result[3].append(' '+' '*n+'|')
result[4].append(' '+"-"*n+' ')
elif a==0:
result[0].append(' '+"-"*n+' ')
result[1].append('|'+' '*n+'|')
result[2].append(' '+" "*n+' ')
result[3].append('|'+' '*n+'|')
result[4].append(' '+"-"*n+' ')
return result
arr=[]
while True:
inp = input("숫자크기와 LCD 변환할 숫자열을 입력하시오")
arr.append(inp)
if inp =='0 0':
arr.remove(inp)
break
print(arr)
print(fun(arr[0]))
for k in arr:
for a in fun(k):
m= fun(k).index(a)
if m==0 or m==2 or m==4:
print(''.join(a))
else:
for j in range(int(k[0])):
print(''.join(a))
맨위에 숫자별 조건 적용한 함수 가 좀 기네요..
def LCD_display(num, size):
num_ex = [int(i) for i in str(num)]
tot_display = [] # 전체 신호 값들
led_mat = [[1,0,1,1,0,1,1,1,1,1], [1,1,1,1,1,0,0,1,1,1], [1,1,0,1,1,1,1,1,1,1], [1,0,1,1,0,1,1,0,1,1],
[1,0,1,0,0,0,1,0,1,0], [1,0,0,0,1,1,1,1,1,1], [0,0,1,1,1,1,1,0,1,1]] # led 숫자 [1234567][0123456789]
led_dir = [0,2,1,1,2,1,1,2] # '-' = 2, '|' = 1, ' ' = 0 신호 출력값
led_fig = [' ', '|', '-']
led_in_dis = [0, 1, 0,
6, 0, 2,
0, 7, 0,
5, 0, 3,
0, 4, 0] # 칸안에 led 배열
for i in num_ex:
display = [[0 for m in range(0, size + 3)] for n in range(0, size * 2 + 3)] # 한칸 크기
line, line_count = 0, 1
for j in led_in_dis:
if j in [1, 4, 7]:
display[line][1:size+1] = [led_dir[j] * led_mat[j - 1][i] for n in range(0, size)]
line += 1
elif j != 0:
line_count += 1
for k in range(line, size + line):
display[k][-2*int(j in [2, 3])] = led_dir[j] * led_mat[j - 1][i]
line += size * (line_count % 2)
tot_display += [display]
for j in range(0, 2 * size + 3):
for i in range(0, len(num_ex)):
for k in range(0, size + 3):
print(led_fig[tot_display[i][j][k]], end='')
print('\t')
num = input("출력하고 싶은 숫자(1억미만)를 입력하세요 : ")
size = input("출력하고 싶은 숫자의 크기를 입력하세요 : (1 ~ 9까지 가능) ")
LCD_display(int(num), int(size))
디지털회로 처럼 만들어봤습니다.
#함수선언
def d_number(s, n):
lnum = [[" " for col in range((s+3)*len(str(n)))] for row in range(2*s+3)]
count = 0
for num in str(n):
num = int(num)
if num == 1:
for i in range(s):
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 2:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+s][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+0] = "|"
elif num == 3 :
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+s][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 4 :
for i in range(s):
lnum[1+i][(s+3)*count+0] = "|"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
lnum[1+s][(s+3)*count+1+i] = "-"
elif num == 5:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+s][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+0] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 6:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+s][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+0] = "|"
lnum[2+s+i][(s+3)*count+0] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 7:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 8:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+s][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+0] = "|"
lnum[2+s+i][(s+3)*count+0] = "|"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 9:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[1+s][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+0] = "|"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
elif num == 0:
for i in range(s):
lnum[0][(s+3)*count+1+i] = "-"
lnum[2+2*s][(s+3)*count+1+i] = "-"
lnum[1+i][(s+3)*count+0] = "|"
lnum[2+s+i][(s+3)*count+0] = "|"
lnum[1+i][(s+3)*count+s+1] = "|"
lnum[2+s+i][(s+3)*count+s+1] = "|"
count += 1
for i in range(len(lnum)):
for j in range(len(lnum[0])):
print(lnum[i][j], end="")
print("")
print("")
#실행
s=[]
n=[]
while True:
try:
s_temp, n_temp = map(int, input("두개의 정수를 입력하세요. ( 1<= s < 10 )( 0<= n <= 99,999,999 )").split(" "))
if 1<= s_temp < 10 and 0<= n_temp <= 99999999:
s.append(s_temp)
n.append(n_temp)
elif s_temp==0 and n_temp==0:
break
else:
print("다시 입력하세요.")
except ValueError:
print("다시 입력하세요.")
for i in range(len(s)):
d_number(s[i], n[i])
# LCD Display
def num_lcd(d, s):
result = [[' ']*(s+2) for _ in range(2*s+3)]
result[0][1:s+1] = d[0]*s
result[s+1][1:s+1] = d[1]*s
result[2*s+2][1:s+1] = d[2]*s
for i in range(1, s+1):
result[i][0] = d[3]
result[s+1+i][0] = d[4]
result[i][s+1] = d[5]
result[s+1+i][s+1] = d[6]
return result
d = [[' ']*10 for _ in range(10)]
d[0] = ['-', ' ', '-', '|', '|', '|', '|']
d[1] = [' ', ' ', ' ', ' ', ' ', '|', '|']
d[2] = ['-', '-', '-', ' ', '|', '|', ' ']
d[3] = ['-', '-', '-', ' ', ' ', '|', '|']
d[4] = [' ', '-', ' ', '|', ' ', '|', '|']
d[5] = ['-', '-', '-', '|', ' ', ' ', '|']
d[6] = ['-', '-', '-', '|', '|', ' ', '|']
d[7] = ['-', ' ', ' ', ' ', ' ', '|', '|']
d[8] = ['-', '-', '-', '|', '|', '|', '|']
d[9] = ['-', '-', '-', '|', ' ', '|', '|']
s, num = map(int, input().split())
result_total = [[' ']*(s+2)*len(str(num)) for _ in range(2*s+3)]
x = 0
for n in str(num):
a = num_lcd(d[int(n)], s)
for i in range(2 * s + 3):
for j in range(s + 2):
result_total[i][j+x] = a[i][j]
x += s+2
for i in range(len(result_total)):
for j in range(len(result_total[0])):
print(result_total[i][j], end='')
print()
파이썬 초보라 그냥 그대로 풀어봤습니다
a = input()
b = int(a[0])+2
for i in [int(x) for x in a.split()[1]]:
if i == 1 or i == 4 :
print(" "*b, end = " ")
else:
print("{0:^{1}}".format("-"*int(a[0]),b), end = " ")
print("")
for j in range(int(a[0])):
for i in [int(x) for x in a.split()[1]]:
b = int(a[0])+2
if i == 1 or i == 2 or i == 3 or i == 7 :
print("{0:>{1}}".format("|",b), end = " ")
elif i == 4 or i == 8 or i == 9 or i == 0:
print("|", end = "")
print("{0:>{1}}".format("|",b-1), end = " ")
else:
print("{0:<{1}}".format("|",b), end = " ")
print("")
for i in [int(x) for x in a.split()[1]]:
if i == 1 or i == 0 or i == 7:
print(" "*b, end = " ")
else:
print("{0:^{1}}".format("-"*int(a[0]),b), end = " ")
print("")
for j in range(int(a[0])):
for i in [int(x) for x in a.split()[1]]:
b = int(a[0])+2
if i == 1 or i == 3 or i == 4 or i == 5 or i == 7 or i == 9 :
print("{0:>{1}}".format("|",b), end = " ")
elif i == 6 or i == 8 or i == 0:
print("|", end = "")
print("{0:>{1}}".format("|",b-1), end = " ")
else:
print("{0:<{1}}".format("|",b), end = " ")
print("")
for i in [int(x) for x in a.split()[1]]:
if i == 1 or i == 4 or i == 7:
print(" "*b, end = " ")
else:
print("{0:^{1}}".format("-"*int(a[0]),b), end = " ")
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#define SIZE 10
int real_size;
int gotoxy_x = 1;
int gotoxy_y = 5;
typedef struct s_n_data
{
int s;
char n[8];
} s_n;
s_n s_n_series[SIZE];
s_n *input(void)
{
int a;
for (a = 0; a < SIZE; a++)
{
scanf("%d%s",
&s_n_series[a].s, s_n_series[a].n);
if (s_n_series[a].s == 0 &&
s_n_series[a].n[0] == '0')
{
printf("\n");
real_size = a;
return s_n_series;
}
}
}
void s_1_n_0(void)
{
int y;
int x;
char s_1_n_0_digit[5][3] =
{
{' ', '-', ' '},
{'|', ' ', '|'},
{' ', ' ', ' '},
{'|', ' ', '|'},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_0_digit[y][x]);
}
}
}
void s_1_n_1(void)
{
int y;
int x;
char s_1_n_1_digit[5][3] =
{
{' ', ' ', ' '},
{' ', ' ', '|'},
{' ', ' ', ' '},
{' ', ' ', '|'},
{' ', ' ', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_1_digit[y][x]);
}
}
}
void s_1_n_2(void)
{
int y;
int x;
char s_1_n_2_digit[5][3] =
{
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', '-', ' '},
{'|', ' ', ' '},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_2_digit[y][x]);
}
}
}
void s_1_n_3(void)
{
int y;
int x;
char s_1_n_3_digit[5][3] =
{
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_3_digit[y][x]);
}
}
}
void s_1_n_4(void)
{
int y;
int x;
char s_1_n_4_digit[5][3] =
{
{' ', ' ', ' '},
{'|', ' ', '|'},
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', ' ', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_4_digit[y][x]);
}
}
}
void s_1_n_5(void)
{
int y;
int x;
char s_1_n_5_digit[5][3] =
{
{' ', '-', ' '},
{'|', ' ', ' '},
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_5_digit[y][x]);
}
}
}
void s_1_n_6(void)
{
int y;
int x;
char s_1_n_6_digit[5][3] =
{
{' ', '-', ' '},
{'|', ' ', ' '},
{' ', '-', ' '},
{'|', ' ', '|'},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_6_digit[y][x]);
}
}
}
void s_1_n_7(void)
{
int y;
int x;
char s_1_n_7_digit[5][3] =
{
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', ' ', ' '},
{' ', ' ', '|'},
{' ', ' ', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_7_digit[y][x]);
}
}
}
void s_1_n_8(void)
{
int y;
int x;
char s_1_n_8_digit[5][3] =
{
{' ', '-', ' '},
{'|', ' ', '|'},
{' ', '-', ' '},
{'|', ' ', '|'},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_8_digit[y][x]);
}
}
}
void s_1_n_9(void)
{
int y;
int x;
char s_1_n_9_digit[5][3] =
{
{' ', '-', ' '},
{'|', ' ', '|'},
{' ', '-', ' '},
{' ', ' ', '|'},
{' ', '-', ' '}};
for (y = 0; y < 5; y++)
{
for (x = 0; x < 3; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_1_n_9_digit[y][x]);
}
}
}
void s_2_n_0(void)
{
int y;
int x;
char s_2_n_0_digit[7][4] =
{
{' ', '-', '-', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', ' ', ' ', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_0_digit[y][x]);
}
}
}
void s_2_n_1(void)
{
int y;
int x;
char s_2_n_1_digit[7][4] =
{
{' ', ' ', ' ', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_1_digit[y][x]);
}
}
}
void s_2_n_2(void)
{
int y;
int x;
char s_2_n_2_digit[7][4] =
{
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', '-', '-', ' '},
{'|', ' ', ' ', ' '},
{'|', ' ', ' ', ' '},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_2_digit[y][x]);
}
}
}
void s_2_n_3(void)
{
int y;
int x;
char s_2_n_3_digit[7][4] =
{
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_3_digit[y][x]);
}
}
}
void s_2_n_4(void)
{
int y;
int x;
char s_2_n_4_digit[7][4] =
{
{' ', ' ', ' ', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_4_digit[y][x]);
}
}
}
void s_2_n_5(void)
{
int y;
int x;
char s_2_n_5_digit[7][4] =
{
{' ', '-', '-', ' '},
{'|', ' ', ' ', ' '},
{'|', ' ', ' ', ' '},
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_5_digit[y][x]);
}
}
}
void s_2_n_6(void)
{
int y;
int x;
char s_2_n_6_digit[7][4] =
{
{' ', '-', '-', ' '},
{'|', ' ', ' ', ' '},
{'|', ' ', ' ', ' '},
{' ', '-', '-', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_6_digit[y][x]);
}
}
}
void s_2_n_7(void)
{
int y;
int x;
char s_2_n_7_digit[7][4] =
{
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_7_digit[y][x]);
}
}
}
void s_2_n_8(void)
{
int y;
int x;
char s_2_n_8_digit[7][4] =
{
{' ', '-', '-', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', '-', '-', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_8_digit[y][x]);
}
}
}
void s_2_n_9(void)
{
int y;
int x;
char s_2_n_9_digit[7][4] =
{
{' ', '-', '-', ' '},
{'|', ' ', ' ', '|'},
{'|', ' ', ' ', '|'},
{' ', '-', '-', ' '},
{' ', ' ', ' ', '|'},
{' ', ' ', ' ', '|'},
{' ', '-', '-', ' '}};
for (y = 0; y < 7; y++)
{
for (x = 0; x < 4; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_2_n_9_digit[y][x]);
}
}
}
void s_3_n_0(void)
{
int y;
int x;
char s_3_n_0_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_0_digit[y][x]);
}
}
}
void s_3_n_1(void)
{
int y;
int x;
char s_3_n_1_digit[9][5] =
{
{' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_1_digit[y][x]);
}
}
}
void s_3_n_2(void)
{
int y;
int x;
char s_3_n_2_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_2_digit[y][x]);
}
}
}
void s_3_n_3(void)
{
int y;
int x;
char s_3_n_3_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_3_digit[y][x]);
}
}
}
void s_3_n_4(void)
{
int y;
int x;
char s_3_n_4_digit[9][5] =
{
{' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_4_digit[y][x]);
}
}
}
void s_3_n_5(void)
{
int y;
int x;
char s_3_n_5_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_5_digit[y][x]);
}
}
}
void s_3_n_6(void)
{
int y;
int x;
char s_3_n_6_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_6_digit[y][x]);
}
}
}
void s_3_n_7(void)
{
int y;
int x;
char s_3_n_7_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_7_digit[y][x]);
}
}
}
void s_3_n_8(void)
{
int y;
int x;
char s_3_n_8_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_8_digit[y][x]);
}
}
}
void s_3_n_9(void)
{
int y;
int x;
char s_3_n_9_digit[9][5] =
{
{' ', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', ' '}};
for (y = 0; y < 9; y++)
{
for (x = 0; x < 5; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_3_n_9_digit[y][x]);
}
}
}
void s_4_n_0(void)
{
int y;
int x;
char s_4_n_0_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_0_digit[y][x]);
}
}
}
void s_4_n_1(void)
{
int y;
int x;
char s_4_n_1_digit[11][6] =
{
{' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_1_digit[y][x]);
}
}
}
void s_4_n_2(void)
{
int y;
int x;
char s_4_n_2_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_2_digit[y][x]);
}
}
}
void s_4_n_3(void)
{
int y;
int x;
char s_4_n_3_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_3_digit[y][x]);
}
}
}
void s_4_n_4(void)
{
int y;
int x;
char s_4_n_4_digit[11][6] =
{
{' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_4_digit[y][x]);
}
}
}
void s_4_n_5(void)
{
int y;
int x;
char s_4_n_5_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_5_digit[y][x]);
}
}
}
void s_4_n_6(void)
{
int y;
int x;
char s_4_n_6_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_6_digit[y][x]);
}
}
}
void s_4_n_7(void)
{
int y;
int x;
char s_4_n_7_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_7_digit[y][x]);
}
}
}
void s_4_n_8(void)
{
int y;
int x;
char s_4_n_8_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_8_digit[y][x]);
}
}
}
void s_4_n_9(void)
{
int y;
int x;
char s_4_n_9_digit[11][6] =
{
{' ', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', ' '}};
for (y = 0; y < 11; y++)
{
for (x = 0; x < 6; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_4_n_9_digit[y][x]);
}
}
}
void s_5_n_0(void)
{
int y;
int x;
char s_5_n_0_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_0_digit[y][x]);
}
}
}
void s_5_n_1(void)
{
int y;
int x;
char s_5_n_1_digit[13][7] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_1_digit[y][x]);
}
}
}
void s_5_n_2(void)
{
int y;
int x;
char s_5_n_2_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_2_digit[y][x]);
}
}
}
void s_5_n_3(void)
{
int y;
int x;
char s_5_n_3_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_3_digit[y][x]);
}
}
}
void s_5_n_4(void)
{
int y;
int x;
char s_5_n_4_digit[13][7] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_4_digit[y][x]);
}
}
}
void s_5_n_5(void)
{
int y;
int x;
char s_5_n_5_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_5_digit[y][x]);
}
}
}
void s_5_n_6(void)
{
int y;
int x;
char s_5_n_6_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_6_digit[y][x]);
}
}
}
void s_5_n_7(void)
{
int y;
int x;
char s_5_n_7_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_7_digit[y][x]);
}
}
}
void s_5_n_8(void)
{
int y;
int x;
char s_5_n_8_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_8_digit[y][x]);
}
}
}
void s_5_n_9(void)
{
int y;
int x;
char s_5_n_9_digit[13][7] =
{
{' ', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 13; y++)
{
for (x = 0; x < 7; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_5_n_9_digit[y][x]);
}
}
}
void s_6_n_0(void)
{
int y;
int x;
char s_6_n_0_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_0_digit[y][x]);
}
}
}
void s_6_n_1(void)
{
int y;
int x;
char s_6_n_1_digit[15][8] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_1_digit[y][x]);
}
}
}
void s_6_n_2(void)
{
int y;
int x;
char s_6_n_2_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_2_digit[y][x]);
}
}
}
void s_6_n_3(void)
{
int y;
int x;
char s_6_n_3_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_3_digit[y][x]);
}
}
}
void s_6_n_4(void)
{
int y;
int x;
char s_6_n_4_digit[15][8] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_4_digit[y][x]);
}
}
}
void s_6_n_5(void)
{
int y;
int x;
char s_6_n_5_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_5_digit[y][x]);
}
}
}
void s_6_n_6(void)
{
int y;
int x;
char s_6_n_6_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_6_digit[y][x]);
}
}
}
void s_6_n_7(void)
{
int y;
int x;
char s_6_n_7_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_7_digit[y][x]);
}
}
}
void s_6_n_8(void)
{
int y;
int x;
char s_6_n_8_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_8_digit[y][x]);
}
}
}
void s_6_n_9(void)
{
int y;
int x;
char s_6_n_9_digit[15][8] =
{
{' ', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 15; y++)
{
for (x = 0; x < 8; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_6_n_9_digit[y][x]);
}
}
}
void s_7_n_0(void)
{
int y;
int x;
char s_7_n_0_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_0_digit[y][x]);
}
}
}
void s_7_n_1(void)
{
int y;
int x;
char s_7_n_1_digit[17][9] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_1_digit[y][x]);
}
}
}
void s_7_n_2(void)
{
int y;
int x;
char s_7_n_2_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_2_digit[y][x]);
}
}
}
void s_7_n_3(void)
{
int y;
int x;
char s_7_n_3_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_3_digit[y][x]);
}
}
}
void s_7_n_4(void)
{
int y;
int x;
char s_7_n_4_digit[17][9] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_4_digit[y][x]);
}
}
}
void s_7_n_5(void)
{
int y;
int x;
char s_7_n_5_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_5_digit[y][x]);
}
}
}
void s_7_n_6(void)
{
int y;
int x;
char s_7_n_6_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_6_digit[y][x]);
}
}
}
void s_7_n_7(void)
{
int y;
int x;
char s_7_n_7_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_7_digit[y][x]);
}
}
}
void s_7_n_8(void)
{
int y;
int x;
char s_7_n_8_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_8_digit[y][x]);
}
}
}
void s_7_n_9(void)
{
int y;
int x;
char s_7_n_9_digit[17][9] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 17; y++)
{
for (x = 0; x < 9; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_7_n_9_digit[y][x]);
}
}
}
void s_8_n_0(void)
{
int y;
int x;
char s_8_n_0_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_0_digit[y][x]);
}
}
}
void s_8_n_1(void)
{
int y;
int x;
char s_8_n_1_digit[19][10] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_1_digit[y][x]);
}
}
}
void s_8_n_2(void)
{
int y;
int x;
char s_8_n_2_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_2_digit[y][x]);
}
}
}
void s_8_n_3(void)
{
int y;
int x;
char s_8_n_3_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_3_digit[y][x]);
}
}
}
void s_8_n_4(void)
{
int y;
int x;
char s_8_n_4_digit[19][10] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_4_digit[y][x]);
}
}
}
void s_8_n_5(void)
{
int y;
int x;
char s_8_n_5_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_5_digit[y][x]);
}
}
}
void s_8_n_6(void)
{
int y;
int x;
char s_8_n_6_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_6_digit[y][x]);
}
}
}
void s_8_n_7(void)
{
int y;
int x;
char s_8_n_7_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_7_digit[y][x]);
}
}
}
void s_8_n_8(void)
{
int y;
int x;
char s_8_n_8_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_8_digit[y][x]);
}
}
}
void s_8_n_9(void)
{
int y;
int x;
char s_8_n_9_digit[19][10] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 19; y++)
{
for (x = 0; x < 10; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_8_n_9_digit[y][x]);
}
}
}
void s_9_n_0(void)
{
int y;
int x;
char s_9_n_0_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_0_digit[y][x]);
}
}
}
void s_9_n_1(void)
{
int y;
int x;
char s_9_n_1_digit[21][11] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_1_digit[y][x]);
}
}
}
void s_9_n_2(void)
{
int y;
int x;
char s_9_n_2_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_2_digit[y][x]);
}
}
}
void s_9_n_3(void)
{
int y;
int x;
char s_9_n_3_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_3_digit[y][x]);
}
}
}
void s_9_n_4(void)
{
int y;
int x;
char s_9_n_4_digit[21][11] =
{
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_4_digit[y][x]);
}
}
}
void s_9_n_5(void)
{
int y;
int x;
char s_9_n_5_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_5_digit[y][x]);
}
}
}
void s_9_n_6(void)
{
int y;
int x;
char s_9_n_6_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_6_digit[y][x]);
}
}
}
void s_9_n_7(void)
{
int y;
int x;
char s_9_n_7_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_7_digit[y][x]);
}
}
}
void s_9_n_8(void)
{
int y;
int x;
char s_9_n_8_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_8_digit[y][x]);
}
}
}
void s_9_n_9(void)
{
int y;
int x;
char s_9_n_9_digit[21][11] =
{
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{'|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|'},
{' ', '-', '-', '-', '-', '-', '-', '-', '-', '-', ' '}};
for (y = 0; y < 21; y++)
{
for (x = 0; x < 11; x++)
{
gotoxy(gotoxy_x + x, gotoxy_y + y);
printf("%c", s_9_n_9_digit[y][x]);
}
}
}
void display(s_n *output)
{
int a;
int b;
for (a = 0; a < real_size; a++)
{
if (output[a].s == 1)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_1_n_0();
}
if (output[a].n[b] == '1')
{
s_1_n_1();
}
if (output[a].n[b] == '2')
{
s_1_n_2();
}
if (output[a].n[b] == '3')
{
s_1_n_3();
}
if (output[a].n[b] == '4')
{
s_1_n_4();
}
if (output[a].n[b] == '5')
{
s_1_n_5();
}
if (output[a].n[b] == '6')
{
s_1_n_6();
}
if (output[a].n[b] == '7')
{
s_1_n_7();
}
if (output[a].n[b] == '8')
{
s_1_n_8();
}
if (output[a].n[b] == '9')
{
s_1_n_9();
}
gotoxy_x += 4;
}
gotoxy_x = 1;
gotoxy_y += 5;
}
if (output[a].s == 2)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_2_n_0();
}
if (output[a].n[b] == '1')
{
s_2_n_1();
}
if (output[a].n[b] == '2')
{
s_2_n_2();
}
if (output[a].n[b] == '3')
{
s_2_n_3();
}
if (output[a].n[b] == '4')
{
s_2_n_4();
}
if (output[a].n[b] == '5')
{
s_2_n_5();
}
if (output[a].n[b] == '6')
{
s_2_n_6();
}
if (output[a].n[b] == '7')
{
s_2_n_7();
}
if (output[a].n[b] == '8')
{
s_2_n_8();
}
if (output[a].n[b] == '9')
{
s_2_n_9();
}
gotoxy_x += 5;
}
gotoxy_x = 1;
gotoxy_y += 7;
}
if (output[a].s == 3)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_3_n_0();
}
if (output[a].n[b] == '1')
{
s_3_n_1();
}
if (output[a].n[b] == '2')
{
s_3_n_2();
}
if (output[a].n[b] == '3')
{
s_3_n_3();
}
if (output[a].n[b] == '4')
{
s_3_n_4();
}
if (output[a].n[b] == '5')
{
s_3_n_5();
}
if (output[a].n[b] == '6')
{
s_3_n_6();
}
if (output[a].n[b] == '7')
{
s_3_n_7();
}
if (output[a].n[b] == '8')
{
s_3_n_8();
}
if (output[a].n[b] == '9')
{
s_3_n_9();
}
gotoxy_x += 6;
}
gotoxy_x = 1;
gotoxy_y += 9;
}
if (output[a].s == 4)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_4_n_0();
}
if (output[a].n[b] == '1')
{
s_4_n_1();
}
if (output[a].n[b] == '2')
{
s_4_n_2();
}
if (output[a].n[b] == '3')
{
s_4_n_3();
}
if (output[a].n[b] == '4')
{
s_4_n_4();
}
if (output[a].n[b] == '5')
{
s_4_n_5();
}
if (output[a].n[b] == '6')
{
s_4_n_6();
}
if (output[a].n[b] == '7')
{
s_4_n_7();
}
if (output[a].n[b] == '8')
{
s_4_n_8();
}
if (output[a].n[b] == '9')
{
s_4_n_9();
}
gotoxy_x += 7;
}
gotoxy_x = 1;
gotoxy_y += 11;
}
if (output[a].s == 5)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_5_n_0();
}
if (output[a].n[b] == '1')
{
s_5_n_1();
}
if (output[a].n[b] == '2')
{
s_5_n_2();
}
if (output[a].n[b] == '3')
{
s_5_n_3();
}
if (output[a].n[b] == '4')
{
s_5_n_4();
}
if (output[a].n[b] == '5')
{
s_5_n_5();
}
if (output[a].n[b] == '6')
{
s_5_n_6();
}
if (output[a].n[b] == '7')
{
s_5_n_7();
}
if (output[a].n[b] == '8')
{
s_5_n_8();
}
if (output[a].n[b] == '9')
{
s_5_n_9();
}
gotoxy_x += 8;
}
gotoxy_x = 1;
gotoxy_y += 13;
}
if (output[a].s == 6)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_6_n_0();
}
if (output[a].n[b] == '1')
{
s_6_n_1();
}
if (output[a].n[b] == '2')
{
s_6_n_2();
}
if (output[a].n[b] == '3')
{
s_6_n_3();
}
if (output[a].n[b] == '4')
{
s_6_n_4();
}
if (output[a].n[b] == '5')
{
s_6_n_5();
}
if (output[a].n[b] == '6')
{
s_6_n_6();
}
if (output[a].n[b] == '7')
{
s_6_n_7();
}
if (output[a].n[b] == '8')
{
s_6_n_8();
}
if (output[a].n[b] == '9')
{
s_6_n_9();
}
gotoxy_x += 9;
}
gotoxy_x = 1;
gotoxy_y += 15;
}
if (output[a].s == 7)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_7_n_0();
}
if (output[a].n[b] == '1')
{
s_7_n_1();
}
if (output[a].n[b] == '2')
{
s_7_n_2();
}
if (output[a].n[b] == '3')
{
s_7_n_3();
}
if (output[a].n[b] == '4')
{
s_7_n_4();
}
if (output[a].n[b] == '5')
{
s_7_n_5();
}
if (output[a].n[b] == '6')
{
s_7_n_6();
}
if (output[a].n[b] == '7')
{
s_7_n_7();
}
if (output[a].n[b] == '8')
{
s_7_n_8();
}
if (output[a].n[b] == '9')
{
s_7_n_9();
}
gotoxy_x += 10;
}
gotoxy_x = 1;
gotoxy_y += 17;
}
if (output[a].s == 8)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_8_n_0();
}
if (output[a].n[b] == '1')
{
s_8_n_1();
}
if (output[a].n[b] == '2')
{
s_8_n_2();
}
if (output[a].n[b] == '3')
{
s_8_n_3();
}
if (output[a].n[b] == '4')
{
s_8_n_4();
}
if (output[a].n[b] == '5')
{
s_8_n_5();
}
if (output[a].n[b] == '6')
{
s_8_n_6();
}
if (output[a].n[b] == '7')
{
s_8_n_7();
}
if (output[a].n[b] == '8')
{
s_8_n_8();
}
if (output[a].n[b] == '9')
{
s_8_n_9();
}
gotoxy_x += 11;
}
gotoxy_x = 1;
gotoxy_y += 19;
}
if (output[a].s == 9)
{
for (b = 0; b < strlen(output[a].n); b++)
{
if (output[a].n[b] == '0')
{
s_9_n_0();
}
if (output[a].n[b] == '1')
{
s_9_n_1();
}
if (output[a].n[b] == '2')
{
s_9_n_2();
}
if (output[a].n[b] == '3')
{
s_9_n_3();
}
if (output[a].n[b] == '4')
{
s_9_n_4();
}
if (output[a].n[b] == '5')
{
s_9_n_5();
}
if (output[a].n[b] == '6')
{
s_9_n_6();
}
if (output[a].n[b] == '7')
{
s_9_n_7();
}
if (output[a].n[b] == '8')
{
s_9_n_8();
}
if (output[a].n[b] == '9')
{
s_9_n_9();
}
gotoxy_x += 12;
}
gotoxy_x = 1;
gotoxy_y += 21;
}
}
}
int main(void)
{
s_n *output;
output = input();
display(output);
return 0;
}
lst_dig = [['-', '|', '|', ' ', '|', '|', '-'], [' ', ' ', '|', ' ', ' ', '|', ' '], ['-', ' ', '|', '-', '|', ' ', '-'], ['-', ' ', '|', '-', ' ', '|', '-'], [' ', '|', '|', '-', ' ', '|', ' '], ['-', '|', ' ', '-', ' ', '|', '-'], ['-', '|', ' ', '-', '|', '|', '-'], ['-', ' ', '|', ' ', ' ', '|', ' '], ['-', '|', '|', '-', '|', '|', '-'], ['-', '|', '|', '-', ' ', '|', '-']] s, n = input().split(' ') s = int(s) disp_h = 3 + s * 2 disp_w = (s + 2) * len(n) disp_pannel = [[' '] * disp_w for i in range(disp_h)] for d in range(len(n)): x_start = d * (s + 2) disp_num = int(n[d]) for i in range(s): disp_pannel[0][x_start + 1 + i] = lst_dig[disp_num][0] disp_pannel[1 + i][x_start] = lst_dig[disp_num][1] disp_pannel[1 + i][x_start + s + 1] = lst_dig[disp_num][2] disp_pannel[s + 1][x_start + 1 + i] = lst_dig[disp_num][3] disp_pannel[s + 2 + i][x_start] = lst_dig[disp_num][4] disp_pannel[s + 2 + i][x_start + s + 1] = lst_dig[disp_num][5] disp_pannel[s * 2 + 2][x_start + 1 + i] = lst_dig[disp_num][6] for i in range(disp_h): for j in range(disp_w): print(disp_pannel[i][j], end="") print('')
r = 1
while r:
inp = input('>>').split()
r = int(inp[0])
num = inp[1]
patern = []
p = []
for i in num:
if i in '146':
p.append(' ' + ' '*r + ' ')
else:
p.append(' ' + '-'*r + ' ')
patern.append(' '.join(p))
for _ in range(r):
p = []
for i in num:
if i in '123':
p.append(' ' + ' '*r + '|')
elif i in '47890':
p.append('|' + ' '*r + '|')
else:
p.append('|' + ' '*r + ' ')
patern.append(' '.join(p))
p = []
for i in num:
if i in '170':
p.append(' ' + ' '*r + ' ')
else:
p.append(' ' + '-'*r + ' ')
patern.append(' '.join(p))
for _ in range(r):
p = []
for i in num:
if i in '134579':
p.append(' ' + ' '*r + '|')
elif i in '680':
p.append('|' + ' '*r + '|')
else:
p.append('|' + ' '*r + ' ')
patern.append(' '.join(p))
p = []
for i in num:
if i in '1479':
p.append(' ' + ' '*r + ' ')
else:
p.append(' ' + '-'*r + ' ')
patern.append(' '.join(p))
for pp in patern:
print(pp)
print('END')
args에 예시와 같이 입력하면 실행됩니다.
package lcd_display;
import java.util.ArrayList;
import java.util.List;
public class lcd_display {
/*
* - :0
* | |:1 2
* - :3
* | |:4 5
* - :6
*/
public static boolean[][] digits =
{
{true, true, true, false, true, true, true},//0
{false, false, true, false, false, true, false},//1
{true, false, true, true, true, false, true},//2
{true, false, true, true, false, true, true},//3
{false, true, true, true, false, true, false},//4
{true, true, false, true, false, true, true},//5
{true, true, false, true, true, true, true},//6
{true, false, true, false, false, true, false},//7
{true, true, true, true, true, true, true},//8
{true, true, true, true, false, true, true}//9
};
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < (args.length)/2; i++) {
List<List<List<Character>>> map = new ArrayList<List<List<Character>>>();
int size = Integer.parseInt(args[i*2]);
for (char character : args[i*2+1].toCharArray()) {
int number = Character.getNumericValue(character);
map.add(mapper(size, number));
}
printList(joinList(map));
System.out.println("");
}
}
public static List<List<Character>> mapper(int size, int number) {
List<List<Character>> map = new ArrayList<List<Character>>();
//편의상 이 자료형을 주석에서는 map이라고 하겠습니다
//크기, 숫자를 입력받아 map으로 변환
for (int i = 0; i < 3; i++) { //가로줄 입력
map.add(new ArrayList<Character>());
map.get(i).add(' ');
for (int j = 0; j < size; j++) {
map.get(i).add((digits[number][i*3]) ? '-' : ' ');
}
map.get(i).add(' ');
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < size; j++) {
int index = i*(size+1)+j+1;
map.add(index, new ArrayList<Character>());
map.get(index).add((digits[number][i*3+1]) ? '|' : ' ');
for (int k = 0; k < size; k++) {
map.get(index).add(' ');
}
map.get(index).add((digits[number][i*3+2]) ? '|' : ' ');
}
}
return map;
}
public static List<List<Character>> joinList(List<List<List<Character>>> lists){
//map 여러 개를 연결
List<List<Character>> newList = new ArrayList<List<Character>>();
for (int i = 0; i < lists.get(0).size(); i++) {
List<Character> newRow = new ArrayList<Character>();
for (List<List<Character>> list : lists) {
newRow.add(' ');
newRow.addAll(list.get(i));
}
newList.add(newRow);
}
return newList;
}
public static void printList(List<List<Character>> map) {
//map 출력
for (List<Character> row : map) {
for (char cell : row) {
System.out.print(cell);
}
System.out.println("");
}
}
}