bouchnina

triangle de pascal

Feb 27th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. /*
  2. Visitez notre page
  3. www.facebook.com/MOBY.c00
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. //#define MAX 7
  9. int main()
  10. {
  11.     //int t[MAX][MAX];
  12.     int i,j,taille;
  13.  
  14.  
  15.     printf("Donnez la taille de la matrice carree pour afficher le triangle de pascal : ");
  16.     scanf("%d",&taille);
  17.     int t[taille][taille];
  18.  
  19.     t[0][0]=1;
  20.     for(i=0;i<taille;i++)
  21.         for(j=1;j<=i;j++)
  22.             {
  23.                 t[i][0]=1;
  24.                 if(i==j)
  25.                     {
  26.                         t[i][j]=1;
  27.                         break;
  28.                     }else
  29.                 t[i][j]=t[i-1][j-1]+t[i-1][j];
  30.             }
  31.  
  32.     for(i=0;i<taille;i++)
  33.         {
  34.             for(j=0;j<=i;j++)
  35.                 printf("%d ",t[i][j]);
  36.             printf("\n");
  37.         }
  38.  
  39.  
  40.     system("pause");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment