根据给定的自然数,在控制台输出如下图形(下图指定为5):
555555555
544444445
543333345
543222345
543212345
543222345
543333345
544444445
555555555
public class Test {
public static void main(String[] args) {
final int NUM = 9;
for (int i = 0 - (NUM - 1); i < NUM; i++) {
for (int j = 0 - (NUM - 1); j < NUM; j++) {
System.out.print(Math.abs(i) >= Math.abs(j) ? Math.abs(i) + 1 : Math.abs(j) + 1);
}
System.out.println();
}
}
}