티스토리 뷰
아래를 함수로 만드시오.
starPrint3(5);
출력: 피라미드모양 별찍기
public class PraybeBlog {
public static void main(String[] args) {
starPrint(5);
}
public static void starPrint(int num) {
for (int i = 1; i <= num; i++) {
for (int j = i; j < num; j++) {
System.out.print(" ");
}
for (int j = 1; j <= i * 2 - 1; j++) {
System.out.print("*");
}
System.out.println();
}
}
}

'Java > Java practice' 카테고리의 다른 글
| [자바] 메소드 활용한 성적 수우미양가 산출 (0) | 2021.11.08 |
|---|---|
| [자바] 별찍기 (직사각형, 직각삼각형, 피라미드, 삼각형) (0) | 2021.11.08 |
| [자바] 구구단 출력 (0) | 2021.10.29 |
| [자바]최소공배수의 갯수 (0) | 2021.10.29 |
| [자바] 짝수 홀수 판별 (0) | 2021.10.29 |
댓글