/* 직각삼각형 출력하기
* "*"의 높이와 너비를 1이라고 했을 때,
* "*"을 이용해 직각 이등변 삼각형을 그리려고합니다.
* 정수 n 이 주어지면 높이와 너비가 n 인 직각 이등변 삼각형을 출력하도록
*
* 3
* *
* **
* ***
*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import java.util.Scanner; public class programmer_0_60 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); /* 다른사람 풀이 for(int i=1; i<=n; i++){ System.out.println("*".repeat(i)); } */ for(int i = 1; i <= n; i++){ for(int k = 1; k <= i; k++) System.out.print("*"); System.out.println(""); } System.out.println("rst = " + n); } } | cs |
'프로그래머스 > lv0' 카테고리의 다른 글
| 특정 문자 제거하기 (0) | 2022.12.05 |
|---|---|
| 문자열 뒤집기 (0) | 2022.12.05 |
| 문자 반복 출력하기 (0) | 2022.12.05 |
| 배열 원소의 길이 (0) | 2022.12.05 |
| 점의 위치 구하기 (0) | 2022.12.05 |