-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cc
28 lines (25 loc) · 843 Bytes
/
test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "bits/stdc++.h"
using namespace std;
vector<vector<int>> generate(int numRows) {
vector<vector<int>> returnVector;
vector<int> firstRow;
firstRow.push_back(1);
returnVector.push_back(firstRow);
for (int i = 1; i < numRows; ++i) {
vector<int> tempVector;
tempVector.push_back(1);
int last = returnVector[i-1][0];
for (int j = 1; j < returnVector[i-1].size(); ++j) {
tempVector.push_back(last + returnVector[i-1][j]);
last = returnVector[i-1][j];
}
tempVector.push_back(1);
returnVector.push_back(tempVector);
}
return returnVector;
}
int main() {
vector<vector<int>> gengen;
gengen = generate(3);
cout << gengen[0][0] << endl;
}