杨辉三角

时间:2019-06-12 01:39:04   收藏:0   阅读:122

#include <stdio.h>

int main()
{

int i,j;

int n,a[100][100]={0};

while(n<1||n>99){
printf("Enter n(0<n<100):");
scanf("%d",&n);
}

for(i=0;i<n;i++)

a[i][0]=1;

for(i=1;i<n;i++)
for(j=1;j<n;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("%4d",a[i][j]);
printf("\n");
}
return 0;

}

技术分享图片

原文:https://www.cnblogs.com/zhushengping/p/11006920.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!