a unknown wrong in Pascal's Triangle for help.


  • 0
    F

    where is wrong in my C program?

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

    i think it's right ,but cant ac.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.