Advertisement
Spocoman

Perfect Diamond

Sep 9th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.  
  8.         for (int i = 0; i < n; i++) {
  9.             System.out.println(" ".repeat (n - (i + 1)) + '*' + "-*".repeat( i));
  10.         }
  11.  
  12.         for (int i = n - 2; i >= 0; i--) {
  13.             System.out.println(" ".repeat (n - (i + 1)) + '*' + "-*".repeat( i));
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement