一、N-S流程图;
二、运行结果;
三、源代码;
cs
# define _CRT_SECURE_NO_WARNINGS
# include <stdio.h>
int main()
{
//初始化变量值;
int a[10][10] = { 0 };
int i, j;
//赋值;
a[0][0] = 1;
//实现杨辉三角;
for (i = 1; i < 10; i++)
{
//内层循环;
for (j = 1; j < i + 1; j++)
{
//每行第一个赋值为1;
a[i][0] = 1;
//运算;
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
}
//循环打印;
for (i = 0; i < 10; i++)
{
//列;
for (j = 0; j < i + 1; j++)
{
//输出;
printf("%5d", a[i][j]);
}
//换行;
printf("\n");
}
return 0;
}