输入 5
输出
1
2 2
3 3
4 4
555555555
#include<stdio.h>
void midspace(int i,int max) {
int cnt = 1;
int x;
if (i >= 2) {
for (int x = i; x > 2; x--) {
cnt += 2;
}
for (int j = 1; j <= cnt; j++) {
if(i!=max) {
printf(" ");
} else {
printf("%d",i);
}
}
}
}
void hollowPyramid(int n) {
int space = n - 1;
int max=n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= space; j++) {
printf(" ");
}
space--;
printf("%d",i);
midspace(i,max);
if(i>1) {
printf("%d",i);
}
printf("\n");
}
}
#include <stdio.h>
void hollowPyramid ( int n );
int main() {
int n;
scanf("%d", &n);
hollowPyramid ( n );
return 0;
}