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

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

Language_Coder_JUNGOL

목록 보기
104/197

문제

자연수 n( 3 <= n <= 10) 을 입력받아 다음과 같이 영문자를 출력하는 프로그램을 작성하시오.

입력

3

출력

코드

package com.jungol.algorihm104;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int inputNumber = sc.nextInt();
        int cnt = 0;
        int cntAskiD = 0;
        int askiA = 65;

        for(int i = 1; i <= inputNumber; i++) {
             for(int j =  askiA; j <  askiA + inputNumber - cnt; j++) {
                char ch = (char)j;
                
                System.out.print(ch);
                 cntAskiD++;
            }
            System.out.println();
            cnt++;
            
            askiA = 65 + cntAskiD;
        }
        sc.close();
    }
}


profile
하루하루 최선을

0개의 댓글