-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dd553c
commit c82cd06
Showing
3 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"java.debug.settings.onBuildFailureProceed": true, | ||
"java.project.sourcePaths": [ | ||
"BOJ/LaTrobeAlgorithm/src/week13", | ||
"BOJ" | ||
"BOJ", | ||
"2290번: LCD Test" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: ::: ::: */ | ||
/* Problem Number: 2290 :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: ahchjang <boj.kr/u/ahchjang> +#+ +#+ +#+ */ | ||
/* +#+ +#+ +#+ */ | ||
/* https://boj.kr/2290 #+# #+# #+# */ | ||
/* Solved: 2024/09/09 23:51:57 by ahchjang ### ### ##.kr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class Main { | ||
static String[] LCD = new String[] { | ||
"1110111", "0010010", "1011101", "1011011", "0111010", | ||
"1101011", "1101111", "1010010", "1111111", "1111011" | ||
}; | ||
|
||
static final char WIDTH = '-'; | ||
static final char HEIGHT = '|'; | ||
static char[][] answer; | ||
|
||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
|
||
int s = Integer.parseInt(st.nextToken()); | ||
String n = st.nextToken(); | ||
|
||
int len = n.length(); | ||
int rows = 2 * s + 3; | ||
int cols = len * (s + 3) + 1; | ||
|
||
answer = new char[rows][cols]; | ||
for (int i = 0; i < rows; i++) { | ||
Arrays.fill(answer[i], ' '); | ||
} | ||
|
||
for (int i = 0; i < len; i++) { | ||
int num = n.charAt(i) - '0'; | ||
drawNumber(num, i * (s + 3), s); | ||
} | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < rows; i++) { | ||
sb.append(new String(answer[i])).append("\n"); | ||
} | ||
System.out.print(sb.toString()); | ||
} | ||
|
||
static void drawNumber(int num, int offset, int s) { | ||
String segments = LCD[num]; | ||
int h = 2 * s + 3; | ||
|
||
if (segments.charAt(0) == '1') { | ||
for (int i = 1; i <= s; i++) | ||
answer[0][offset + i] = WIDTH; | ||
} | ||
if (segments.charAt(1) == '1') { | ||
for (int i = 1; i <= s; i++) | ||
answer[i][offset] = HEIGHT; | ||
} | ||
if (segments.charAt(2) == '1') { | ||
for (int i = 1; i <= s; i++) | ||
answer[i][offset + s + 1] = HEIGHT; | ||
} | ||
if (segments.charAt(3) == '1') { | ||
for (int i = 1; i <= s; i++) | ||
answer[s + 1][offset + i] = WIDTH; | ||
} | ||
if (segments.charAt(4) == '1') { | ||
for (int i = s + 2; i < h - 1; i++) | ||
answer[i][offset] = HEIGHT; | ||
} | ||
if (segments.charAt(5) == '1') { | ||
for (int i = s + 2; i < h - 1; i++) | ||
answer[i][offset + s + 1] = HEIGHT; | ||
} | ||
if (segments.charAt(6) == '1') { | ||
for (int i = 1; i <= s; i++) | ||
answer[h - 1][offset + i] = WIDTH; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 2290번: LCD Test - <img src="https://static.solved.ac/tier_small/9.svg" style="height:20px" /> Silver II | ||
|
||
<!-- performance --> | ||
|
||
<!-- 문제 제출 후 깃허브에 푸시를 했을 때 제출한 코드의 성능이 입력될 공간입니다.--> | ||
|
||
<!-- end --> | ||
|
||
## 문제 | ||
|
||
[문제 링크](https://boj.kr/2290) | ||
|
||
|
||
<p>지민이는 새로운 컴퓨터를 샀다. 하지만 새로운 컴퓨터에 사은품으로 온 LC-디스플레이 모니터가 잘 안나오는 것이다. 지민이의 친한 친구인 지환이는 지민이의 새로운 모니터를 위해 테스트 할 수 있는 프로그램을 만들기로 하였다.</p> | ||
|
||
|
||
|
||
## 입력 | ||
|
||
|
||
<p>첫째 줄에 두 개의 정수 s와 n이 들어온다. (1 ≤ s ≤ 10, 0 ≤ n ≤ 9,999,999,999)이다. n은 LCD 모니터에 나타내야 할 수 이며, s는 크기이다.</p> | ||
|
||
|
||
|
||
## 출력 | ||
|
||
|
||
<p>길이가 s인 '<code>-</code>'와 '<code>|</code>'를 이용해서 출력해야 한다. 각 숫자는 모두 s+2의 가로와 2s+3의 세로로 이루어 진다. 나머지는 공백으로 채워야 한다. 각 숫자의 사이에는 공백이 한 칸 있어야 한다.</p> | ||
|
||
|
||
|
||
## 소스코드 | ||
|
||
[소스코드 보기](Main.java) |