Java 使用 for 循环打印数字金字塔图案 (n=4)
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + ' ');
}
for (int j = i - 1; j >= 1; j--) {
System.out.print(j + ' ');
}
System.out.println();
}
原文地址: https://www.cveoy.top/t/topic/jYGC 著作权归作者所有。请勿转载和采集!