Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. int ** generate(int A, int *number_of_rows) {
  2. // SAMPLE CODE
  3.  
  4. *number_of_rows = A;
  5. int **res = (int **)malloc(A * sizeof(int *));
  6. // DO STUFF HERE
  7. int i; int j;
  8. for(i=0;i<*number_of_rows;i++){
  9. res[i] = (int *)malloc((i+1)*sizeof(int));
  10. for(j=0;j<=i;j++){
  11. if(j==0 || i==j){
  12. res[i][j]=1;
  13. }
  14. else{
  15. res[i][j]= res[i-1][j]+res[i-1][j-1];
  16. }
  17. }
  18. }
  19. return res;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement