杨辉三角形
#include <stdio.h>
int main ()
{
int n;
scanf("%d",&n);
int i,j;
int a[34][34];
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
a[i][0]=1;
a[i][j]=1;
if(i>1&&j>0&&i!=j)
{
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
printf("%d ",a[i][j]);
}
printf("\n");
}
return 0;
}

本文来自博客园,作者:早晨9点,转载请注明原文链接:https://www.cnblogs.com/onesun/p/15823392.html

浙公网安备 33010602011771号