별찍기-12 (상하대칭)

han.user();·2023년 4월 11일
0

구름

목록 보기
20/20
post-thumbnail

import java.io.*;

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

        for (int i = 1; i <= input; i++) {
            for (int j = 0; j < input - i; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j < i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
        input -= 1;
        for (int i = 1; i <= input; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j <= input - i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}
profile
I'm still hungry.

0개의 댓글