全网唯一递归法:
vector<vector<int>> generate(int numRows) {vector<int> v;vector<vector<int>>vn;if (numRows == 1){v.push_back(1);vn.push_back(v);v.clear();return vn;//递归记得return}if (numRows == 2){v.push_back(1);vn.push_back(v);v.clear();v.push_back(1);v.push_back(1);vn.push_back(v);v.clear();return vn;//递归记得return}else{vn = generate(numRows - 1);//递归精髓v = vn[numRows - 2];vector<int> v2;v2.resize(numRows, 1);for (int i = 1; i < numRows - 1; i++){v2[i] = v[i-1] + v[i];}vn.push_back(v2);v.clear();}return vn;
}