/**
* Return an array of arrays of size *returnSize.
* The sizes of the arrays are returned as *returnColumnSizes array.
* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
*/
int** generate(int numRows, int* returnSize, int** returnColumnSizes) {
*returnSize=numRows;
int* column=(int*)malloc(sizeof(int) * numRows);
for(int i=0;i<numRows;i++ ) column[i]=i+1;
int** array=(int**)malloc(sizeof(int*) * numRows);
for(int i=0;i<numRows;i++) array[i]=(int*)malloc(sizeof(int) * (i+1));
for(int i=0;i<numRows;i++){
array[i][0]=1;
array[i][i]=1;
}
for(int i=2;i<numRows;i++){
for(int j=1;j<i;j++){
printf("%d %d\n",i,j);
array[i][j]=array[i-1][j-1]+array[i-1][j];
}
}
*returnColumnSizes=column;
return array;
}
标签:returnSize,int,numRows,杨辉三角,array,118 From: https://www.cnblogs.com/llllmz/p/18084691