Language_Coder 550 : 반복제어문3 - 자가진단3

boom.jun.cho·2022년 4월 17일
0

Language_Coder_JUNGOL

목록 보기
101/197

문제

자연수 n을 입력받아서 다음과 같이 출력하는 프로그램을 작성하시오.

입력

3

출력

코드

package com.jungol.algorihm101;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

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

        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
        sc.close();
    }
}



profile
하루하루 최선을

0개의 댓글