思考:杨辉三角形
#include<stdio.h> #include<cstring> int main() { int n; char d; int a[31][31] = {0}; while (scanf_s("%d%c",&n,&d)!=EOF) { a[0][1] = 1; int i; for (i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { a[i][j] = a[i - 1][j - 1] + a[i - 1][j]; printf("%d", a[i][j]); if (j < i) printf(" "); } printf(" "); } printf(" "); } }