Advertisement
paganoantonio

Untitled

Mar 29th, 2023 (edited)
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1.         Scanner scan = new Scanner(System.in);
  2.  
  3.         System.out.println("Immettere il numero di righe (metΓ  del diamante):");
  4.         int n = scan.nextInt();
  5.         for (int a = 1; a <= n; a++) {
  6.             for (int b = 1; b <= a; b++ ) {
  7.                 System.out.print("*");
  8.             }
  9.             for (int c = 2; c <= a; c++) {
  10.                 System.out.print("*");
  11.             }
  12.             System.out.println();
  13.         }
  14.  
  15.         for (int j = (n - 1); j > 0; j--) {
  16.             for (int g = j; g > 0; g--) {
  17.             System.out.print("*");
  18.         }
  19.             for (int h = 2; h <= j; h++) {
  20.                 System.out.print("*");
  21.             }
  22.             System.out.println();
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement