diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..f3117e1 --- /dev/null +++ b/Main.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + if (scanner.hasNextInt()) { + int n = scanner.nextInt(); + for (int i = 0; i < n; i++) { + int stars = (i < n / 2) ? 2 * i + 1 : 2 * (n - 1 - i) + 1; + int spaces = (n - stars) / 2; + for (int j = 0; j < spaces; j++) System.out.print(" "); + for (int j = 0; j < stars; j++) System.out.print("*"); + System.out.print(" "); + for (int j = 0; j < stars; j++) System.out.print("*"); + for (int j = 0; j < spaces; j++) System.out.print(" "); + System.out.println(); + } + } + } +}