본문 바로가기

알고리즘/JAVA

[JAVA] 백준 알고리즘 2441 : 별찍기 - 4

반응형

 

 

첫째 줄에는 별 N개, 둘째 줄에는 별 N-1개, ..., N번째 줄에는 별 1개를 출력해 봅니다. (오른쪽 정렬)

 

 

 

  문제

 

*****
 ****
  ***
   **
    *

 

 

 

 

 

 

 

  소스

 

import java.util.*; public class Main {     public static void main(String[] args) throws Exception {         Scanner sc = new Scanner(System.in);         int input = sc.nextInt();         for(int i=1; i<=input; i++) { for (int j=1; j<=input; j++) { if (j>=i) { System.out.print("*"); } else { System.out.print(" "); } } System.out.println(); }     } }

 

 

 

 

 

  출처


https://www.acmicpc.net/problem/2441

 

 

반응형