import java.util.Scanner;
public class ex3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("정수를 입력하시오>>");
int num = sc.nextInt();
for(int i=0;i<num;i++) {
for(int j=0;j<5-i;j++) {
System.out.print("*");
}
System.out.println();
}
}
}
결과
정수를 입력하시오>>5
*****
****
***
**
*
'명품JAVA프로그래밍 > 3장 반복문과 배열 그리고 예외처리' 카테고리의 다른 글
[명품JAVA프로그래밍] 3장 실습문제 5번 (0) | 2021.12.21 |
---|---|
[명품JAVA프로그래밍] 3장 실습문제 4번 (0) | 2021.12.21 |
[명품JAVA프로그래밍] 3장 실습문제 2번 (0) | 2021.12.21 |
[명품JAVA프로그래밍] 3장 실습문제 1번 (0) | 2021.12.21 |
[명품JAVA프로그래밍] 3장 Open Challenge (0) | 2021.12.21 |