Pascal's triangle: Difference between revisions

Content added Content deleted
(simplified CL program)
Line 133:
=={{header|C++}}==
<cpp>#include <iostream>
#include <algorithm>
 
void genPyrN(int rows) {
Line 145 ⟶ 146:
int *thisRow = new int[i+1];
thisRow[0] = last[0]; // beginning of row
for std::transform(int&last[0], j&last[i], =&last[1], &thisRow[1; j], std::plus< iint>()); j++) // middle of row
//sum from the last row
thisRow[j] = last[j-1] + last[j];
thisRow[i] = last[i-1]; // end of row