PS/백준

2446 별 찍기 - 9

함께자라기 2022. 3. 13. 00:18


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());

        for(int i=0; i < n; i++) {
            for(int j=0; j < i; j++) {
                System.out.print(" ");
            }

            for (int k = 0; k < (2 * n - 1) - (2 * i); k++) {
                System.out.print("*");
            }

            System.out.println();
        }

        for(int i=0; i < n - 1; i++) {
            for(int j=1; j < (n- 1) - i; j++) {
                System.out.print(" ");
            }

            for (int k = 0; k < 3 + 2 * i; k++) {
                System.out.print("*");
            }

            System.out.println();
        }
    }
}