(int n)
| 10 | // 3 2 1 2 3 |
| 11 | //4 3 2 1 2 3 4 |
| 12 | static void pattern8(int n) { |
| 13 | for (int row = 1; row <= n; row++) { |
| 14 | |
| 15 | for (int space = 0; space < n-row; space++) { |
| 16 | System.out.print(" "); |
| 17 | } |
| 18 | |
| 19 | for (int col = row; col >= 1; col--) { |
| 20 | System.out.print(col + " "); |
| 21 | } |
| 22 | for (int col = 2; col <= row; col++) { |
| 23 | System.out.print(col + " "); |
| 24 | } |
| 25 | |
| 26 | System.out.println(); |
| 27 | } |
| 28 | } |
| 29 | } |