public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=1; i<n+1; i++){
for(int j=i; j<n+1; j++){
System.out.print("*");
}
System.out.println();
}
}
}
▶ j의 초기값은 i에서 잔달받고,
▶ n+1은 고정되어 있고, j값이 커지면서 for문안에 있는 조건문을 탈출한다.
'프로그래머스(자바) > LV.0(자바)' 카테고리의 다른 글
문자열 정렬하기(1) - replaceAll(), Stream(), mapToInt() (0) | 2022.11.24 |
---|---|
직각삼각형 출력하기★ - 독특하게 풀 수도 있다. + 이중for문 (0) | 2022.11.24 |
모음제거 → String 클래스 →contains(), replaceAll()★ + 정규식★ (0) | 2022.11.22 |
옷가게 할인 받기 - return시 int형으로 타입 맞추기 (0) | 2022.11.22 |
제곱수 판별하기 -Math.sqrt() (0) | 2022.11.22 |