-
boj)16505 - 별PS/boj 2020. 11. 14. 11:271234567891011121314151617181920212223242526272829303132333435363738394041424344454647import java.io.*;import java.util.Scanner;public class boj_16505 {static char[][] map;static int N, length;static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));public static void main(String[] args) throws IOException {Scanner sc = new Scanner(System.in);N = sc.nextInt();length = (int)Math.pow(2, N);map = new char[length][length];func(0, 0, length);// printfor (int i = 0; i < length; i++) {for (int j = 0; j < length; j++) {if (j == length - i) break;if (map[i][j] == '*') bw.write(map[i][j]);else bw.write(' ');}bw.newLine();}bw.flush();bw.close();}private static void func(int x, int y, int length) {// base conditionif (length == 1) {map[x][y] = '*';return;}// recursionint newLength = length/2;func(x, y, newLength);func(x, y + newLength, newLength);func(x + newLength, y, newLength);}}
cs - 재귀
- 재귀랑 좀 친해진거 같다.
'PS > boj' 카테고리의 다른 글
boj)5904 - Moo 게임 (0) 2020.11.15 boj)2447 - 별 찍기 - 10 (0) 2020.11.14 boj)1992 - 쿼드트리 (0) 2020.11.13 boj)1780 - 종이의 개수 (0) 2020.11.13 boj)17478 - 재귀함수가 뭔가요? (0) 2020.11.12