http://oj.leetcode.com/problems/pascals-triangle/
输入行数,输出一个杨辉三角(帕斯卡三角), 如果rowNum ==0, 则输出 [ ]
class Solution {
public:
vector
> generate(int numRows) {
vector
> result;
vector
one_row; one_row.push_back(1); if(numRows > 0) { result.push_back(one_row); } for(int i = 1; i <= numRows-1; i++) { vector
tmp; for(int j = 0; j <= i; j++) { if(j == 0 || j == i) tmp.push_back(1); else { tmp.push_back(result[i-1][j-1] + result[i-1][j]); } } result.push_back(tmp); } return result; } };