Advertisement
Guest User

thierry

a guest
Jan 30th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define TAILLE 100
  4.  
  5. main(){
  6. int i,j,ordre;
  7. int triangle [TAILLE][TAILLE];
  8.  
  9. do{
  10. system ("CLS");
  11. printf ("\nTriangle de Pascal");
  12. printf ("\n\nOrdre de votre triangle: ");
  13. scanf ("%d", &ordre);
  14. } while(ordre <0 || ordre > TAILLE);
  15. for(i=0;i<=ordre;i++){
  16. triangle [i][0]= 1;
  17. triangle [i][i]= 1;
  18.  
  19. }for(i=2;i<=ordre;i++){
  20. for(j=1;j<=ordre;j++){
  21. triangle[i][j] = (triangle[i-1][j-1]+triangle[i-1][j]);
  22. }
  23. }
  24.  
  25.  
  26.  
  27.  
  28. for(i=0;i<=ordre;i++){
  29. printf("\n|");
  30. for(j=0;j<ordre;j++){
  31. printf("%5d" ,triangle [i][j]);
  32. triangle [i][j] = (triangle[i][j]);
  33. }
  34. printf(" |");
  35. printf("\n\n");
  36.  
  37.  
  38.  
  39. }
  40. system("PAUSE");
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement