자연수 n을 입력받아서 n개의 줄에 n+1개의 숫자 혹은 문자로 채워서 다음과 같이 출력하는 프로그램을 작성하시오
3
package com.jungol.algorithm105;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int inputNumber = sc.nextInt();
int cntChar = 0;
int cntNum = 0;
int askiA = 65;
int startN = 1;
int cntN = 0;
for(int i = 1; i <= inputNumber; i++) {
for(int j = startN; j < startN + inputNumber - cntN; j++) {
System.out.print(j + " ");
cntNum++;
}
cntN++;
startN = 1 + cntNum;
for(int j = askiA; j <= askiA + cntChar; j++) {
char ch = (char)j;
System.out.print(ch + " ");
}
System.out.println();
cntChar++;
askiA = askiA + cntChar;
}
sc.close();
}
}