알고리즘/백준 / / 2021. 9. 7. 00:53

[백준 BAEKJOON] 2439번 별 찍기 - 2 문제 (JAVA)

소스코드
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		sc.close();
		
		for (int i = 1; i <= count; i++) {	//행 출력
			
			for (int j = count; j > i; j--) {	//공백 출력
				System.out.print(" ");
			}
			
			for (int j = 1; j <= i; j++) {	//별 찍기
				System.out.print("*");
			} //for
			System.out.println();
		} //for

	} // main

} //class
반응형
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유