Feelings and experiences: be familiar with Pascal's triangle algorithm, emerging issues for the middle of the variable does not know how to determine the relationship between the rows and columns, and later given a specific value judgments, let me have a deeper understanding.
Output Pascal's Triangle:
#include<stdio.h>
int main()
{
int a[10][10];
int i,j,n;
printf("enter n:");
scanf("%d",&n);
a[0][0]=1;
for(i=0;i<n;i++)
{
a[i][0]=1;
for(j=0;j<=i/2;j++)
{
if(j==0)
a[i][j]=a[0][0];
else
a[i][j]=a[i-1][j-1]+a[i-1][j];
a[i][i-j]=a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
printf("%5d",a[i][j]);
printf("\n");
}
return 0;
}
int main()
{
int a[10][10];
int i,j,n;
printf("enter n:");
scanf("%d",&n);
a[0][0]=1;
for(i=0;i<n;i++)
{
a[i][0]=1;
for(j=0;j<=i/2;j++)
{
if(j==0)
a[i][j]=a[0][0];
else
a[i][j]=a[i-1][j-1]+a[i-1][j];
a[i][i-j]=a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
printf("%5d",a[i][j]);
printf("\n");
}
return 0;
}