This is the Yang Hui's triangle, also known as Jia Xiansan. This is the most closely related to our current study is the coefficient rule of the 2-term powers expansion. As shown in Jia Xiansan, the third number in line 3rd corresponds to the two number and the square formula in turn.
The Yang Hui's triangle is a number of triangular tables of numbers, in general form as follows:
.................................................
The rule of the Yang Hui's triangle is that its two hypotenuse is made up of the number 1, while the rest is equal to the sum of two digits on its shoulders.
The code is as follows:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int i,j,k,arr[10][10]={0};/*arr[11 ][11] must be initialized, initialized to {0}*/
printf ("Print out Yang Hui's triangle: \ n");
for (i=0;i<10;i++)
{/* First print out the first column and diagonal number, both 1, and the 12th line has been printed * *
arr[i][0]=1;
arr[i][i]=1;
}
for (i=2;i<10;i++)
{/* The Yang Hui's triangle arrangement is analyzed by the rule * * for
(j=1;j<10;j++)
{
arr[i][j]=arr[i-1][j-1]+arr[ I-1][J];
}
for (i=0;i<10;i++)
{for
(k=0;k<10-i;k++)
{
printf ("");
}
for (j=0;j<=i;j++)
{
printf ("%d", arr[i][j]);
printf ("\ n");
}
System ("pause");
return 0;
}
I hope this article is helpful to the learning of C program algorithm design.