Advertisement
LOVEGUN

Exercice 4 (Serie Etude)

Mar 2nd, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.83 KB | None | 0 0
  1. Program exercice4;
  2. Uses Wincrt;
  3. Type
  4.   mat = Array [1..10,1..10] Of Integer;
  5. Var
  6.   l,c,i,j: Integer;
  7.   t: mat;
  8.   f: Text;
  9.  
  10. Procedure remplir2 (Var f:Text;Var t:mat);
  11. Var
  12.   i,j,c: Integer;
  13. Begin
  14.   Assign (f,'c:\bac\matrice.txt');
  15.   Reset (f);
  16.   For i:=1 To 4 Do
  17.     For j:=1 To 5 Do
  18.       Readln (f,t[i,j]);
  19.   Close (f);
  20. End;
  21.  
  22. Procedure remplir (Var t:mat;Var l,c:Integer);
  23. Var
  24.   i,j: Integer;
  25. Begin
  26.   Repeat
  27.     Write ('Saisir L: ');
  28.     Readln (l);
  29.     Write ('Saisir C: ');
  30.     Readln (c);
  31.   Until (1<j) And (1<l);
  32.   For i:=1 To l Do
  33.     For j:=1 To c Do
  34.       Begin
  35.         Write ('T[',i,',',j,']: ');
  36.         Readln (t[i,j]);
  37.       End;
  38. End;
  39. Function sommec (t:mat;l,j:Integer): Integer;
  40. Var
  41.   s,i: Integer;
  42. Begin
  43.   s := 1;
  44.   For i:=1 To l Do
  45.     s := s*t[i,j];
  46.   sommec := s;
  47. End;
  48. Function sommel (t:mat;c,i:Integer): Integer;
  49. Var
  50.   s,j: Integer;
  51. Begin
  52.   s := 0;
  53.   For j:=1 To c Do
  54.     s := s+t[i,j];
  55.   sommel := s;
  56. End;
  57.  
  58. Function chainel (t:mat;c,i:Integer): String;
  59. Var
  60.   ch,ch1: String;
  61.   j: Integer;
  62. Begin
  63.   ch := '';
  64.   For j:=1 To c Do
  65.     Begin
  66.       Str (t[i,j],ch1);
  67.       ch := ch+ch1+'+';
  68.     End;
  69.   Delete (ch,Length(ch),1);
  70.   chainel := ch;
  71. End;
  72. function chainec (t:mat;l,j:integer):string;
  73. Var
  74. ch,ch1:string;
  75. i:integer;
  76. Begin
  77.     ch:='';
  78.     for i:=1 to l Do
  79.         begin
  80.         str (t[i,j],ch1);
  81.         ch:=ch+ch1+'*';
  82.         end;
  83.         delete (ch,Length(ch),1);
  84.         chainec:=ch;
  85. end;
  86. Procedure traitement (t:mat;l,c:Integer);
  87. Var
  88.   i,j,sl,sc: Integer;
  89. Begin
  90.   For i:=1 To l Do
  91.     Begin
  92.       sl := sommel(t,c,i);
  93.       For j:=1 To c Do
  94.         Begin
  95.           sc := sommec(t,l,j);
  96.           If sc=sl Then
  97.             Writeln ('T[',i,',',j,']: ',t[i,j],' (car ',chainel(t,c,i),'=',chainec(t,l,j),')');
  98.         End;
  99.     End;
  100. End;
  101. Begin
  102.   remplir (t,l,c);
  103.   traitement (t,l,c);
  104. End.
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement