题解 | #杨辉三角#
杨辉三角
https://www.nowcoder.com/practice/e671c6a913d448318a49be87850adbcc
#include <cstdio> int main(){ int n,i,j; int arr[30][30]; scanf("%d",&n); for (i = 0; i < n; ++i) { for (j = 0; j <= i; ++j) { if (j == 0 || i == j){ arr[i][j] = 1; }else{ arr[i][j] = arr[i - 1][j] + arr[i - 1][j - 1]; } printf("%5d",arr[i][j]); } printf("\n"); } }