标签:span turned not i++ sizeof arrays nbsp col tco
/**
* Return an array of arrays.
* The sizes of the arrays are returned as *columnSizes array.
* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
*/
int** generate(int numRows, int** columnSizes) {
int **array;
array = (int **)malloc(sizeof(int *) * numRows);
*columnSizes =(int*) malloc(sizeof(int ) * numRows);
int i, j;
for(i = 0; i < numRows; i++)
{
(*columnSizes)[i] = i+1;
array[i] = (int*)malloc(sizeof(int) *(i+1));
array[i][0] = 1;
array[i][i] = 1;
}
for (i = 1; i < numRows; i++)
{
for (j = 1; j < i; j++)
{
array[i][j] = array[i-1][j-1] + array[i-1][j];
}
}
return array;
}
array
标签:span turned not i++ sizeof arrays nbsp col tco
原文地址:https://www.cnblogs.com/xinfenglee/p/10047969.html