class Solution {
public:
    vector<int> getRow(int rowIndex) {
       vector<int> result;
       int i = 0;
       int j = 0;
       if(rowIndex < 0) {
           return result;
       }
       
       result.push_back(1);
       if(rowIndex == 0){
           return result;
       }
       
       for(i = 1; i <= rowIndex; i++){
           for(j = result.size() - 1; j > 0; j--){//注意。此处不能够写成for(j =1; j j<result.size(); j++){

               result[j] = result[j] + result[j - 1];
           }
           result.push_back(1);
       }
       return result;
    }
};

posted on 2017-08-10 17:53  yutingliuyl  阅读(197)  评论(0编辑  收藏  举报