LOVEGUN

Application 1 (Les Algorithmes Recurrents)

Jan 14th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.79 KB | None | 0 0
  1. Program app1;
  2. Uses Wincrt;
  3. Type
  4.   tab = Array [1..20,1..20] Of Integer;
  5. Var
  6.   t: tab;
  7.   n: Integer;
  8.  
  9. Function Somme_mat (t:tab;n:Integer): Integer;
  10. Var
  11.   i,j,s: Integer;
  12. Begin
  13.   s := 0;
  14.   For i:=1 To n Do
  15.     For j:=1 To n Do
  16.             s:=s+t[i,j];
  17.         Somme_mat:=s;
  18. End;
  19. Procedure traitement (Var t:tab;Var n:Integer);
  20. Var
  21.   i,j: Integer;
  22. Begin
  23.   Repeat
  24.     Write('Saisir N: ');
  25.     Readln (n);
  26.   Until (4<=n) And (n<=20);
  27.   Randomize;
  28.   For i:=1 To n Do
  29.     For j:=1 To n Do
  30.       t[i,j] := Random(20);
  31.      ClrScr;
  32.      writeln ('La Matrice: ');
  33.      For i:=1 To n Do
  34.     Begin
  35.       Writeln;
  36.       For j:=1 To n Do
  37.         Write (t[i,j],' | ');
  38.     End;
  39.         writeln;writeln;
  40.         writeln ('La Somme: ');
  41.         writeln;
  42.         writeln (Somme_mat(t,n));
  43. End;
  44. Begin
  45.   traitement (t,n);
  46. End.
  47.  
Advertisement
Add Comment
Please, Sign In to add comment