#include<stdio.h>
#define N 10
void main()
{
int i, j, a[N][N];
for (i = 0; i < N; i++)
{
a[i][i] = 1;
a[i][0] = 1;
}
for (i = 2; i < N; i++)
for (j = 1; j <= i - 1; j++)
{
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
for (i = 0; i < N; i++)
{
for (j = 0; j <= i; j++)
printf("%5d", a[i][j]);
printf("\n");
}
}
第十四天杨辉三角形
最新推荐文章于 2024-11-07 23:24:07 发布