LOVEGUN

Exercice 6

Dec 1st, 2020 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.44 KB | None | 0 0
  1. Program exercice6;
  2. Uses Wincrt;
  3. Type
  4.   mat = Array [1..99,1..99] Of Integer;
  5. Var
  6.   m,n: Integer;
  7.   a: mat;
  8.  
  9. Procedure remplir (Var a:mat;Var m,n:Integer);
  10. Var
  11.   i,j: Integer;
  12. Begin
  13.   Repeat
  14.     Writeln ('Saisir le nombre de ligne');
  15.     Readln (m);
  16.     Writeln ('Saisir le nombre de collone');
  17.     Readln (n);
  18.   Until (m>0) And (n>0) And (m<=8) And (n<=10);
  19.   For i:=1 To m Do
  20.     For j:=1 To n Do
  21.       Begin
  22.         Writeln ('A[',i,',',j,'] : ');
  23.         Readln (a[i,j]);
  24.       End;
  25. End;
  26. Procedure somme (a:mat;i,n:Integer;Var s:Integer;Var chs:String);
  27. Var
  28.   j: Integer;
  29.   x: String;
  30. Begin
  31.   s := 0;
  32.   chs := '';
  33.   For j:=1 To n Do
  34.     Begin
  35.       s := s+a[i,j];
  36.       Str (a[i,j],x);
  37.       chs := chs+ x+'+';
  38.     End;
  39.   Delete (chs,Length(chs),1);
  40. End;
  41. Procedure produit (a:mat;i,m:Integer;Var p:Integer;Var chp:String);
  42. Var
  43.   j: Integer;
  44.   x: String;
  45. Begin
  46.   p := 1;
  47.   chp := '';
  48.   For j:=1 To m Do
  49.     Begin
  50.       p := p*a[j,i];
  51.       Str (a[j,i],x);
  52.       chp := chp+ x+'*';
  53.     End;
  54.   Delete (chp,Length(chp),1);
  55. End;
  56. Procedure affiche (a:mat;m,n:Integer);
  57. Var
  58.   p,i,s,j: Integer;
  59.   chp,chs: String;
  60. Begin
  61.   Writeln;
  62.   For i:=1 To m Do
  63.     For j:=1 To n Do
  64.       Begin
  65.         somme (a,i,n,s,chs);
  66.         produit (a,j,m,p,chp);
  67.         If s=p Then
  68.           Writeln ('A[',i,',',j,'] : ', a[i,j],' (car ',chs,'=',chp,')');
  69.       End;
  70. End;
  71. Begin
  72.   remplir (a,m,n);
  73.   affiche (a,m,n);
  74. End.
  75.  
Add Comment
Please, Sign In to add comment