(int n)
| 12 | // 2 1 2 |
| 13 | // 1 |
| 14 | static void pattern7(int n) { |
| 15 | for (int row = 1; row <= 2 * n; row++) { |
| 16 | |
| 17 | int c = row > n ? 2 * n - row: row; |
| 18 | |
| 19 | for (int space = 0; space < n-c; space++) { |
| 20 | System.out.print(" "); |
| 21 | } |
| 22 | |
| 23 | for (int col = c; col >= 1; col--) { |
| 24 | System.out.print(col + " "); |
| 25 | } |
| 26 | for (int col = 2; col <= c; col++) { |
| 27 | System.out.print(col + " "); |
| 28 | } |
| 29 | |
| 30 | System.out.println(); |
| 31 | } |
| 32 | } |
| 33 | } |