文章
11
粉丝
223
获赞
14
访问
55.8k
// 计算关键: v[i][j] = v[i - 1][j] + v[i - 1][j - 1];
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
while (cin >> n && n)
{
vector<vector<int>> v(n + 1, vector<int>(n + 1, 0));
v[1][1] = 1;
for (int i = 2; i <= n; ++i)
for (int j = 1; j <= i; ++j)
v[i][j] = v[i - 1][j] + v[i - 1][j - 1];
// 从第二行开始输出
for (int i = 2; i <= n; ++i)
{
for (int j = 1; j <= i; ++j)
cout << v[i][j] << " ";
...
登录后发布评论
暂无评论,来抢沙发