// 4ms
1
class Solution { 2 public: 3 vector<int> getRow(int rowIndex) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 vector<int> v; 7 v.push_back(1); 8 if(rowIndex==0) 9 return v; 10 v.push_back(1); 11 if(rowIndex==1) 12 return v; 13 int i; 14 int t,q; 15 for(int j=1;j<rowIndex;j++) 16 { 17 t=v[0]; 18 for(i=1;i<=j;i++) 19 { 20 q=v[i]; 21 v[i]=t+v[i]; 22 t=q; 23 } 24 v.push_back(1); 25 } 26 return v; 27 } 28 };

 

posted on 2013-06-03 15:12  宇睿  阅读(141)  评论(0编辑  收藏  举报