#include<stdio.h>
int main()
{
int i = 0;
int j = 0;
int n = 0;
int k = 0;
int arr[30][30] = { 1 };//定义一个二维数组
printf("请输入打印的行数n:>");
scanf("%d", &n);
//最两边初始化为1
for (i = 0; i < n; i++)
{
arr[i][0] = 1;
arr[i][i] = 1;
}
for (i = 2; i < n; i++)
{
for (j = 1; j < i; j++)
{
arr[i][j] = (arr[i - 1][j - 1]) + (arr[i - 1][j]);
}
}
for (i = 0; i < n; i++)
{
for (j = 0; j < (2 * n - 2 * i); j++)
{
printf(" ");
}
for (j = 0; j <= i; j++)
{
printf("%4d", arr[i][j]);
}
printf("\n");
}
return 0;
}