DAY 11
0

## 解題思路:

### C版本:

``````int** generate(int numRows, int** columnSizes) {
int i=0;
int j=0;
if(numRows == 0)
return 0;
int ** returnArray = (int **)malloc(sizeof(int *) * numRows);
*columnSizes = (int *)malloc(sizeof(int)*numRows);

for(i=0; i<numRows; i++)
{
(*columnSizes)[i] = i+1;
returnArray[i] = (int *)malloc(sizeof(int) * (i+1));
for(j=0; j<i+1; j++)
{
if( (0 == j)  || (i == j) )
returnArray[i][j] = 1;
else
returnArray[i][j] = returnArray[i-1][j-1] + returnArray[i-1][j];
}
}
return returnArray;
}
``````

### Javascript版本:

``````var generate = function(n) {
var cur = [1,1]
var result = [1,1,1]
var temp = []
temp.push([1],[1,1]);
if(n==1){return [1]}
if(n==2){return result}

for(var i = 2 ; i < n ; i ++){
var next = [1]
for(var j = 0 ; j < cur.length-1  ; j ++){
next.push(cur[j]+cur[j+1])
}
next.push(1)
temp.push(next)
cur = next;
}
return temp
};
``````

## 程式Github分享:

https://github.com/SIAOYUCHEN/leetcode

## 本日分享:

One day, perhaps you will find the most touching thing is not that you have finished, but you finally have the courage to start.