#做了很久还是不会,能帮忙看一下是哪里错了嘛谢谢(;´д`)ゞ
#include <iostream>
using namespace std;
int shuzu(int n) { //确定数组个数,同时用于计算当前位置
int f;
if (n == 1) {
int f = 1;
}
if (n > 1) {
f = n + shuzu(n - 1);
}
cout << f;
return (f);
}
int derta(int n) { //输出
int a[shuzu(n) + 1];
cout << shuzu(n) + 1;
a[1] = 1;
a[2] = 1;
a[3] = 1;
if (n == 1) {
cout << 1;
} else if (n == 2) {
cout << 1 << endl;
cout << 1 << " " << 1;
} else {
cout << 1 << endl;
cout << 1 << " " << 1;
for (int i = 3; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (j == 1 || j == i) {
cout << 1 << " ";
} else {
a[shuzu(i - 1) + j] = a[shuzu(i - 2) + j] + a[shuzu(i - 2) + j - 1];
}
}
cout << endl;
}
}
}
int main() {
int n;
cout << "输入要输出的行数" << endl;
cin >> n;
derta(n);
}