问题遇到的现象和发生背景
LeetCode刷题遇到程序bug ,118.杨辉三角
显示一堆奇怪的错误,看不懂..
不过我感觉我的算法应该没问题
问题相关代码,请勿粘贴截图
/**
- 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)
{
int** yh = (int**)malloc(sizeof(int)*numRows);
int cnt = 1;
for(int i = 0;i<numRows;i++)
{
}*returnColumnSizes[i] = cnt++;
*returnSize = numRows;
for (int i = 0;i < numRows;i++)
{
}yh[i] = (int*)malloc(sizeof(int)*(i + 1)); for(int j = 0;j < i + 1;j++) { if (j == 0 || j == i) yh[i][j] = 1; else { yh[i][j] = yh[i - 1][j] + yh[i - 1][j - 1]; } }
return yh;
}
运行结果及报错内容
我想要达到的结果
求指点