[작성일: 2023. 09. 07]
https://www.acmicpc.net/problem/2444
풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
for (int i = 1; i < num; i++) {
for (int j = 1; j <= num - i; j++) {
System.out.print(" ");
}
for (int k = 1; k < i + i; k++) {
System.out.print("*");
}
System.out.println();
}
for (int i = num; i > 0; i--) {
for (int k = 0; k < num-i; k++) {
System.out.print(" ");
}
for (int j = 1; j < i + i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}