/** * Note: The returned array must be malloced, assume caller calls free(). */ int* getRow(int rowIndex, int* returnSize){ int n=rowIndex; int r=0; int *p=(int*)malloc(sizeof(int)*(rowIndex+1)); for(r=0;r<rowIndex+1;r++) { p[r]=1; if(r==0 || r==n) { p[r]=1; } else { int product=1; int k,s,t=1; k=r+1; while(k<=n ) { product=product*k; k++; } p[r]=product; if(n-r!=0) { s=n-r; while(s>1) { t=t*s; s--; } } p[r]=p[r]/t; } } *returnSize=rowIndex+1; return p; }
479,001,600
13
6,227,020,800
2,147,483,647
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)