Pascal’s Triangle

vector<vector<int>> generate(int num)
      {
          vector<vector<int>> result;
          vector<int> array;
          for (int i = 1; i <= num; i++)
          {
              for (int j = i - 2; j > 0; j--)
              {
                  array[j] = array[j - 1] + array[j];
              }
              array.push_back(1);
              result.push_back(array);
          }
      }
View Code

 

posted @ 2016-08-08 10:49  牧马人夏峥  阅读(93)  评论(0编辑  收藏  举报