diff --git "a/Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" "b/Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" new file mode 100644 index 00000000..ee3cf369 --- /dev/null +++ "b/Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" @@ -0,0 +1,63 @@ +```java +import java.io.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + if (N == 1) { + System.out.println("*"); + return; + } + + char[][] map = new char[3 + 4 * (N-1)][1 + 4 * (N-1)]; + for (int i = 0; i < 3+4*(N-1); i++) { + for (int j = 0; j < 1+4*(N-1); j++) { + map[i][j] = ' '; + } + } + + int r = N * 2; + int c = N * 2 - 2; + int directionR = 1; + int directionC = -1; + int weight = 1; + for (int i = 0; i < 1+4*(N-1); i++) { + if (i % 2 == 0) { + directionR *= -1; + weight += 2; + for (int j = 0; j < weight; j++) { + r = j!=0 ? r + directionR : r; + map[r][c] = '*'; + } + } else { + directionC *= -1; + for (int j = 0; j < weight; j++) { + c = j!=0 ? c + directionC : c; + map[r][c] = '*'; + } + } + } + + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + for (int i = 0; i < 3+4*(N-1); i++) { + for (int j = 0; j < 1+4*(N-1); j++) { + if (i == 0) { + bw.write("*"); + continue; + } + if (i == 1 && j >= 1) continue; + if (j == 4*N - 4) { + bw.write(map[i][j]); + } else { + bw.write(map[i][j]); + } + } + bw.write("\n"); + } + bw.flush(); + bw.close(); + } +} +```