Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine()),
- spaces = 2 * n - 2, stars = 2;
- for (int row = 0; row < n; row++) {
- System.out.println(" ".repeat(spaces) + "*".repeat(stars));
- spaces -= 2;
- stars += 2;
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- System.out.println("*".repeat(stars) + " ".repeat(spaces));
- spaces += 2;
- stars -= 2;
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- System.out.println("*".repeat(stars) + " ".repeat(spaces));
- if (spaces > 0 && stars > 0) {
- spaces -= 2;
- stars += 2;
- }
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- System.out.println(" ".repeat(spaces) + "*".repeat(stars));
- spaces += 2;
- stars -= 2;
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- System.out.println(" ".repeat(spaces) + "*".repeat(stars));
- if (spaces > 0 && stars > 0) {
- spaces -= 2;
- stars += 2;
- }
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < n; row++) {
- System.out.println("*".repeat(stars) + " ".repeat(spaces));
- spaces += 2;
- stars -= 2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement