Pascal Dreieck drucken
vector<vector<int>> generate(int numRows) {
vector<vector<int>> ans;
vector<int> first(1,1);
ans.push_back(first);
int n = numRows;
for(int i=1; i<n; i++){
vector<int> second(i+1,0);
for(int j=0; j<i+1; j++){
if(j==0 || j==i) second[j] = 1;
else{
second[j] = first[j] + first[j-1];
}
}
ans.push_back(second);
first = second;
}
return ans;
}
Charan 316