倒杨辉三角

#include<stdio.h>

int main()

{

int i, j, k, n;

int a[100][100];

while (scanf(“%d”, &n) != EOF)

{

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

{

a[i][i] = 1;

a[i][0] = 1;

}

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

for (j = 1; j < i; j++)

a[i][j] = a[i – 1][j] + a[i – 1][j – 1];

for (i = n – 1; i >= 0; i–)

{

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

printf(” “);

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

printf(“%d “, a[i][j]);

printf(“\n”);

}

}

return 0;

}

    原文作者:杨辉三角问题
    原文地址: https://blog.csdn.net/yihanyifan/article/details/78817319
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞