LOVEGUN

Procedure Triangle De Pascal

Jan 14th, 2021 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.61 KB | None | 0 0
  1. Procedure triangle_pascal (Var t:tab;n:Integer);
  2. Var
  3.   i,j,l,c: Integer;
  4. Begin
  5.     //saisie de N
  6.         repeat
  7.             Writeln ('Saisir N');
  8.           Readln (n);
  9.         until (0<n) and (n<15);
  10.     //remplissage des bords du triangle de 1
  11.     For i:=1 To n Do
  12.     Begin
  13.       t[i,1] := 1;
  14.       t[i,i] := 1;
  15.     End;
  16.     //remplissage du reste du triangle avec la formule (T[l, c] = T[l-1, c] + T[l-1, c-1])
  17.   For i:=3 To n Do
  18.     For j:=2 To n-1 Do
  19.       t[i, j] := t[i-1, j] + t[i-1, j-1];
  20.     //affichage de la matrice
  21.     For i:=1 To n Do
  22.     Begin
  23.       Writeln;
  24.       For j:=1 To i Do
  25.         Write (t[i,j],' | ');
  26.     End;
  27. End;
Add Comment
Please, Sign In to add comment