#include<stdio.h>
#define a 10
void yanghui(int arr[][a],int n)
{for (int i= 0; i < n; i++)
{
int j = 0;
for (; j <= i; j++)
{
if (i == j || j == 0)
{
arr[i][j]=1;
}
else
{
arr[i][j] = arr[i - 1][j] + arr[i - 1][j - 1];
}
}
}
}
int main()
{
int n = 0;
int arr[a][a];yanghui(arr, a);
for (int i = 0; i <= a; i++)
{
printf("\n");
for (int j = 0; j <= i; j++)
{
printf("%d ",arr[i][j]);
}
}
}
###杨辉三角
最新推荐文章于 2024-11-14 19:06:32 发布