LOVEGUN

Exercice 7

Dec 3rd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.63 KB | None | 0 0
  1.  Program exercice7;
  2. Uses Wincrt;
  3. Type
  4.   mat = Array [1..99,1..99] Of Integer;
  5. Var
  6.   l,c: Integer;
  7.   a,max,min: mat;
  8. Procedure remplir (Var a:mat;Var l,c:Integer);
  9. Var
  10.   i,j: Integer;
  11. Begin
  12.   Repeat
  13.     Writeln ('Saisir le nombre de ligne');
  14.     Readln (l);
  15.     Writeln ('Saisir le nombre de collone');
  16.     Readln (c);
  17.   Until (l>0) And (c>0);
  18.   For i:=1 To l Do
  19.     For j:=1 To c Do
  20.       Begin
  21.         Writeln ('A[',i,',',j,'] : ');
  22.         Readln (a[i,j]);
  23.       End;
  24. End;
  25. Function maxx (a:mat;i,c:Integer): Integer;
  26. Var
  27.   j,x: Integer;
  28. Begin
  29.   x := a[i,1];
  30.   For j:=1 To c Do
  31.     If x<=a[i,j] Then x := a[i,j] ;
  32.   maxx := x;
  33. End;
  34. Function minn (a:mat;i,j:Integer): Integer;
  35. Var
  36.   x,g: Integer;
  37. Begin
  38.   x := a[i,j];
  39.   For g:=1 To l Do
  40.     If x>a[g,j] Then x := a[g,j] ;
  41.   minn := x;
  42. End;
  43. Procedure traitmin (a:mat;Var min:mat;l,c:Integer);
  44. Var
  45.   i,j,m: Integer;
  46. Begin
  47.   For i:=1 To l Do
  48.     For j:=1 To c Do
  49.       Begin
  50.         m := minn(a,i,j);
  51.         If a[i,j]<>m Then min[i,j] := 0
  52.         Else min[i,j] := 1;
  53.       End;
  54. End;
  55. Procedure traitmax (a:mat;Var max:mat;l,c:Integer);
  56. Var
  57.   i,j,m: Integer;
  58. Begin
  59.   For i:=1 To l Do
  60.     Begin
  61.       m := maxx(a,i,c);
  62.       For j:=1 To c Do
  63.         If a[i,j]<>m Then max[i,j] := 0
  64.         Else max[i,j] := 1;
  65.     End;
  66. End;
  67.  
  68. procedure affiche (a,max,min:mat;l,c:integer);
  69. Var
  70. m:mat;
  71. i,j:integer;
  72. begin
  73.     for i:=1 to l Do
  74.         for j:=1 to c Do
  75.             if (min[i,j]=1) and (max[i,j]=1) Then
  76.             writeln ('A[',i,',',j,'] : ', a[i,j]);
  77. end;
  78.  
  79. Begin
  80.   remplir (a,l,c);
  81.   traitmax (a,max,l,c);
  82.     traitmin (a,min,l,c);
  83.     affiche (a,max,min,l,c);
  84.    
  85. End.
  86.  
Advertisement
Add Comment
Please, Sign In to add comment