""의 높이와 너비를 1이라고 했을 때, ""을 이용해 직각 이등변 삼각형을 그리려고합니다. 정수 n 이 주어지면 높이와 너비가 n 인 직각 이등변 삼각형을 출력하도록 코드를 작성해보세요.
입력 #1
3
출력 #1
*
**
***
입출력 예 #1
n이 3이므로 첫째 줄에 1개, 둘째 줄에 2개, 셋째 줄에 * 3개를 출력합니다.
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0; i < n; i++){
for(int j = 0; j < i+1 ; j++){
System.out.print("*");
}
System.out.println("");
}
}
}
참고사이트: https://school.programmers.co.kr/learn/courses/30/lessons/120823/solution_groups?language=java