(int n)
| 12 | // * * |
| 13 | // * |
| 14 | private static void pattern6(int n) { |
| 15 | for (int row = 0; row < 2 * n; row++) { |
| 16 | int totalColsInRow = row > n ? 2 * n - row: row; |
| 17 | |
| 18 | int noOfSpaces = n - totalColsInRow; |
| 19 | for (int s = 0; s < noOfSpaces; s++) { |
| 20 | System.out.print(" "); |
| 21 | } |
| 22 | |
| 23 | for (int col = 0; col < totalColsInRow; col++) { |
| 24 | System.out.print("* "); |
| 25 | } |
| 26 | System.out.println(); |
| 27 | } |
| 28 | } |
| 29 | } |