LOVEGUN

Application 3 (Les Algorithmes Recurrents)

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