Code :
- unit produit;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls;
- type
- matrice1=array[1..2,1..3]of integer;
- matrice2=array[1..3,1..2]of integer;
- matrice=array[1..2,1..2]of integer;
- type
- TForm1 = class(TForm)
- Button2: TButton;
- RichEdit3: TRichEdit;
- procedure Button2Click(Sender: TObject);
- private
- function Produit2(MatA:matrice1;MatB:matrice2):matrice;
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button2Click(Sender: TObject);
- var
- i,j,k:integer;
- ok:boolean;
- begin
- matrice1[1][1]:=1; //erreur [Error] produit.pas(38): '(' expected but '[' found
- matrice1[1][2]:=2;
- matrice1[1][3]:=3;
- matrice1[2][1]:=4;
- matrice1[2][2]:=5;
- matrice1[2][3]:=6;
- matrice1[1][1]:=1;
- matrice1[1][2]:=2;
- matrice1[2][1]:=3;
- matrice1[2][2]:=4;
- matrice1[3][1]:=5;
- matrice1[3][2]:=6;
- matrice:=Produit2(matrice1,matrice2);
- end;
- function TForm1.Produit2(MatA,MatB:Matrice):matrice;
- var i,j,k:integer;
- MatC:matrice;
- begin
- for i:=1 TO high(MatA) DO
- for j:=1 TO high(MatA) DO
- begin
- MatC[i,j]:=0;
- for k:=1 TO high(MatA) DO
- MatC[i,j]:=MatC[i,j]+MatA[i,k]*MatB[k,j];
- end;
- result:=matc;
- end;
- end.
|