C语言实现杨辉三角算法
#include <stdio.h>
int main() { int n, i, j, coef = 1; printf('Enter the number of rows: '); scanf('%d', &n); for (i = 0; i < n; i++) { for (j = 0; j <= i; j++) { if (j == 0 || i == 0) coef = 1; else coef = coef * (i - j + 1) / j; printf('%d ', coef); } printf('\n'); } return 0; }
原文地址: https://www.cveoy.top/t/topic/oM1I 著作权归作者所有。请勿转载和采集!