본문 바로가기

프로그래밍/백준

백준 acm 2448 - 별찍기 (11)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = (int) (Math.log(N / 3/ Math.log(2));
        String[] star = new String[N];
 
        star[0= "  *  ";
        star[1= " * * ";
        star[2= "*****";
 
        int copy = 3;
 
        for (int  i = 1; i <= K; i++) {
            for (int j = 0; j < copy; j++) {
                star[copy + j] = star[j] + " " + star[j];
                for (int k = 0; k < copy / 3; k++) {
                    star[j] = "   " + star[j] + "   ";
                }
            }
            copy *= 2;
        }
 
        for(int i=0; i<copy; i++) {
            System.out.println(star[i]);
        }
    }
}
cs


'프로그래밍 > 백준' 카테고리의 다른 글

2577 숫자의 개수  (0) 2017.10.14
1152 단어의 개수  (0) 2017.10.07
백준 acm 4673 - 셀프 넘버  (0) 2017.10.01
백준 acm 7453 - 합이 0인 네 정수  (0) 2017.07.30
백준 acm 1915 가장 큰 정사각형  (0) 2017.07.19