fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int n = 15;
  6. int s[25]={1,1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4, 5,5,5,5, 6,6,6, 7,7};
  7. int p[25][25+1+25] = { 0 };
  8. p[0][25] = 1;
  9.  
  10. for(int i = 1; i < n; i++)
  11. {
  12. for(int j = 1; j < (25+1+24); j++)
  13. {
  14. p[i][j] = p[i-1][j-1] + p[i-1][j+1];
  15. }
  16. }
  17.  
  18. for(int i = 0; i < n; i++)
  19. {
  20. for(int j = 0; j < (25+1+25); j++)
  21. {
  22. if(p[i][j])
  23. {
  24. printf("%*d ",s[n-1],p[i][j]);
  25. }
  26. }
  27. printf("\n");
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
   1 
   1    1 
   1    2    1 
   1    3    3    1 
   1    4    6    4    1 
   1    5   10   10    5    1 
   1    6   15   20   15    6    1 
   1    7   21   35   35   21    7    1 
   1    8   28   56   70   56   28    8    1 
   1    9   36   84  126  126   84   36    9    1 
   1   10   45  120  210  252  210  120   45   10    1 
   1   11   55  165  330  462  462  330  165   55   11    1 
   1   12   66  220  495  792  924  792  495  220   66   12    1 
   1   13   78  286  715 1287 1716 1716 1287  715  286   78   13    1 
   1   14   91  364 1001 2002 3003 3432 3003 2002 1001  364   91   14    1