下列C++程序实现了输出杨辉三角形,代码中横线部分应该填入的是( )。
#include <iostream> using namespace std; #define N 35 int a[N][N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) { if (j == 1 || j == i) a[i][j] = 1; else __________ // 在此处填入选项 } for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) cout << a[i][j]; cout<<endl; } return 0; }
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
a[i][j] = a[i][j - 1] + a[i - 1][j];
a[i][j] = a[i - 1][j] + a[i - 1][j];
a[i][j] = a[i - 1][j - 1] + a[i][j];