Pascal's Triangle II

问题:输出杨辉三角的第n行

class Solution {
public:
    vector<int> getRow(int rowIndex) {
        vector<int> vec;
        int a[100][100];
        a[0][0]=1;
        int j,i;
        for(i=1;i<=rowIndex;i++)
        {
            a[i][0]=1;
            for(j=1;j<i;j++)
            {
                a[i][j]=a[i-1][j-1]+a[i-1][j];
            }
            a[i][j]=1;
        }
        for(i=0;i<=rowIndex;i++) vec.push_back(a[rowIndex][i]);
        return vec;
    }
};

  

posted @ 2014-08-06 17:30  calmound  阅读(116)  评论(0编辑  收藏  举报