1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
int n = 6;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < n - i; j++) {
System.out.print(" "); // 打印空格
}
for (int k = -i; k <= i; k++) {
if (k == 0 || k == 1) {
continue;
}
System.out.print(" " + Math.abs(k)); // 打印數字
}
System.out.println();
}