Advertisement
Guest User

Untitled

a guest
Sep 27th, 2014
244
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. void main()
  4. {
  5. int triangle[10][10];
  6. int i,j;
  7.  
  8. for (i=0 ; i<10 ; i++) {
  9. triangle[i][0] = 1;
  10. triangle[i][i] = 1;
  11. }
  12.  
  13. for (i=2 ; i<10 ; i++)
  14. for (j=1 ; j<i ; j++)
  15. triangle[i][j] = triangle[i-1][j-1] + triangle[i-1][j];
  16.  
  17. /* printing */
  18.  
  19. for (i=0 ; i<10 ; i++) {
  20. for (j=0 ; j<=i ; j++)
  21. printf("%d ", triangle[i][j]);
  22. putchar('\n');
  23. }
  24. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement