#include”stdio.h”#include”stdlib.h”#include”string.h”int main(){int i = 0;int j = 0;int a[10][10] = { 0 };for (i = 0; i <= 9; i++){for (j = 0; j <= 9; j++){if (j == 0){a[i][0] = 1;}if (i == j){a[i][j] = 1;}}}for (i = 2; i <= 9; i++){for (j = 1; j <= i – 1; j++)//去掉每行的首尾两个元素{a[i][j] = a[i – 1][j – 1] + a[i – 1][j];}}for (i = 0; i <= 9; i++){for (j = 1; j <= 9 – i; j++)printf(” “);for (j = 0; j <= i; j++)printf(“%5d”, a[i][j]);printf(“\n”);}system(“pause”);return 0;}
c语言中关于杨辉三角问题
原文作者:杨辉三角问题
原文地址: https://blog.csdn.net/weixin_36194037/article/details/78242238
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://blog.csdn.net/weixin_36194037/article/details/78242238
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。