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