lundi 12 septembre 2016
    1. Program Triangle_Pascal;
    2. Type matrice = Array [1..15, 1..15] of Integer;
    3. Var T : matrice; N : Integer;
    4. Procedure triangle (n : Integer ; Var T:matrice);
    5. Var l, c : Integer;
    6. Begin T[1,1]:=1;
    7. For l:=2 To n Do
    8. Begin
    9. T[l,1]:=1;
    10. For c:=2 To l-1 Do
    11. T[l,c]:=T[l-1,c]+T[l-1,c-1];
    12. T[l,l]:=1;
    13. End;
    14. End;
    15. Procedure Afficher (n : Integer ; T:matrice);
    16. Var l, c : Integer;
    17. Begin
    18. For l:=1 To n Do
    19. Begin
    20. For c:=1 To l Do
    21. Write (T[l,c], ' ');
    22. Writeln ;
    23. End;
    24. End;
    25. (*********************************************)
    26. Begin
    27. Repeat
    28. Writeln ('Donner la taille du triangle : ');
    29. Readln (n);
    30. Until n in [2..15];
    31. Triangle (n, T);
    32. Afficher (n, T);
    33. End.

0 commentaires:

Enregistrer un commentaire

Page Facebook

Turbo Pascal 32 bits

Turbo Pascal 64 bits