1 class Solution {
 2 public:
 3     vector<vector<int> > generate(int numRows) {
 4         // Start typing your C/C++ solution below
 5         // DO NOT write int main() function
 6         vector<int> v ;
 7         vector<vector<int> > re;
 8         if(numRows==0)
 9             return re;
10         int i;
11         int j;
12         v.push_back(1);
13         re.push_back(v);
14         if(numRows==1)
15             return re;
16         v.push_back(1);
17         re.push_back(v);
18         if(numRows==2)
19             return re;
20         for(i=1;i<numRows-1;i++)
21         {
22             v.clear();
23             v.push_back(1);
24             for(j=0;j<re[re.size()-1].size()-1;j++)
25             {
26                 v.push_back(re[re.size()-1][j]+re[re.size()-1][j+1]);
27             }
28             v.push_back(1);
29             re.push_back(v);
30             
31         }
32         
33         
34     }
35 };

 

posted on 2013-06-03 14:53  宇睿  阅读(124)  评论(0编辑  收藏  举报