#include <stdio.h>
int yanghui(int x, int y){
int z;
if (y == 1 || y == x)
return 1;
else
{
z = c(x - 1, y - 1) + c(x - 1, y);//上一行两个数字的和
return z;
}
}
int main()
{
int i, j, n;
printf("请输入杨辉三角形的行数:");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 0; j <n-i; j++)
printf(" ");//空格个数和后面的%6d的数字是二倍关系
for (j = 1; j <= i; j++)
printf("%6d", yanghui(i, j));
putchar('\n');
}
return 0;
}