[백준, BOJ 2446] 별 찍기 - 9 (java)
Problem Solving/BOJ

[백준, BOJ 2446] 별 찍기 - 9 (java)

728x90

출처-https://www.acmicpc.net/problem/2446

 

2446번: 별 찍기 - 9

첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.

www.acmicpc.net


728x90

 

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();

		for (int i=1;i<=N;i++) {
			for (int j=1;j<=i-1;j++)
				System.out.print(" ");
			for (int j=1;j<=2*(N-i+1)-1;j++)
				System.out.print("*");
			System.out.println();
		}
		
		for (int i=1;i<N;i++) {
			for (int j=N-i-1;j>=1;j--)
				System.out.print(" ");
			for (int j=1;j<=2*i+1;j++)
				System.out.print("*");
			System.out.println();
		}
	}
}
728x90