#89 B
The rule is simple. First determin the number of rows to print, then for every row follow the rule.
Total rows = 2n + 1.
The ith row has 2i + 1 digits to print, from 0 to i then to 0.
The ith row skip 2n - 2i spaces.
Accepted.
#include <stdio.h>
#include <string.h>
int main() {
int n;
scanf("%d", &n);
int i,j,k;
for( i=0;i<n;i++ ) {
k = 2*n - 2*i;
for( j=0;j<k;j++ )
printf(" ");
k = 2*i + 1;
for( j=0;j<i;j++ )
printf("%d ", j);
for( ;j>0;j-- )
printf("%d ", j);
printf("%d\n",j);
}
for( ;i>=0;i-- ) {
k = 2*n - 2*i;
for( j=0;j<k;j++ )
printf(" ");
k = 2*i + 1;
for( j=0;j<i;j++ )
printf("%d ", j);
for( ;j>0;j-- )
printf("%d ", j);
printf("%d\n",j);
}
return 0;
}