• 문제 링크
https://www.acmicpc.net/problem/5354
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
int t = read();
while (t-- > 0) {
int n = read();
for (int i = 0; i < n; i++, sb.append('\n'))
for (int j = 0; j < n; j++) sb.append(i == 0 || j == 0 || i == n - 1 || j == n - 1 ? '#' : 'J');
sb.append('\n');
}
bw.write(sb.toString());
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 1296 팀 이름 정하기 - Implementation / Java (0) | 2025.05.04 |
---|---|
[백준] 14909 양수 개수 세기 - Implementation / Java (0) | 2025.05.03 |
[백준] 1270 전쟁 - 땅따먹기 - Data Structure / Java (0) | 2025.05.01 |
[백준] 1764 듣보잡 - Data Structure / Java (0) | 2025.04.30 |
[백준] 15595 정답 비율 계산하기 - Data Structure / Java (0) | 2025.04.29 |
댓글