Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program exercice4;
- Uses Wincrt;
- Type
- mat = Array [1..10,1..10] Of Integer;
- Var
- l,c,i,j: Integer;
- t: mat;
- f: Text;
- Procedure remplir2 (Var f:Text;Var t:mat);
- Var
- i,j,c: Integer;
- Begin
- Assign (f,'c:\bac\matrice.txt');
- Reset (f);
- For i:=1 To 4 Do
- For j:=1 To 5 Do
- Readln (f,t[i,j]);
- Close (f);
- End;
- Procedure remplir (Var t:mat;Var l,c:Integer);
- Var
- i,j: Integer;
- Begin
- Repeat
- Write ('Saisir L: ');
- Readln (l);
- Write ('Saisir C: ');
- Readln (c);
- Until (1<j) And (1<l);
- For i:=1 To l Do
- For j:=1 To c Do
- Begin
- Write ('T[',i,',',j,']: ');
- Readln (t[i,j]);
- End;
- End;
- Function sommec (t:mat;l,j:Integer): Integer;
- Var
- s,i: Integer;
- Begin
- s := 1;
- For i:=1 To l Do
- s := s*t[i,j];
- sommec := s;
- End;
- Function sommel (t:mat;c,i:Integer): Integer;
- Var
- s,j: Integer;
- Begin
- s := 0;
- For j:=1 To c Do
- s := s+t[i,j];
- sommel := s;
- End;
- Function chainel (t:mat;c,i:Integer): String;
- Var
- ch,ch1: String;
- j: Integer;
- Begin
- ch := '';
- For j:=1 To c Do
- Begin
- Str (t[i,j],ch1);
- ch := ch+ch1+'+';
- End;
- Delete (ch,Length(ch),1);
- chainel := ch;
- End;
- function chainec (t:mat;l,j:integer):string;
- Var
- ch,ch1:string;
- i:integer;
- Begin
- ch:='';
- for i:=1 to l Do
- begin
- str (t[i,j],ch1);
- ch:=ch+ch1+'*';
- end;
- delete (ch,Length(ch),1);
- chainec:=ch;
- end;
- Procedure traitement (t:mat;l,c:Integer);
- Var
- i,j,sl,sc: Integer;
- Begin
- For i:=1 To l Do
- Begin
- sl := sommel(t,c,i);
- For j:=1 To c Do
- Begin
- sc := sommec(t,l,j);
- If sc=sl Then
- Writeln ('T[',i,',',j,']: ',t[i,j],' (car ',chainel(t,c,i),'=',chainec(t,l,j),')');
- End;
- End;
- End;
- Begin
- remplir (t,l,c);
- traitement (t,l,c);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement