Provo kodin e meposhtem:
Kodi:
type
TMatrica = attay[0..2, 0..2] of integer; // madhesia e matrices eshte 3x3 (0,1,2)
procedure MbledhjaRreshtave(var A : TMatrica);
function ShumezimiMatrivace(A, B : TMatrica): TMatrica;
implementation
procedure MbledhjaRreshtave(var A : TMatrica);
var
shuma : integer;
i,j : integer;
begin
for i:= 0 to 2 do // per secilen rresht te matrices
begin
shuma := 0;
for j:= 0 to 2 do
begin
shuma := shuma + A[i,j]; // mbledh anetaret e rreshtit i
A[i,0] := shuma; // vendose shumen ne shtyllen e pare
end;
end;
end;
function ShumezimiMatrivace(A, B : TMatrica): TMatrica;
var
prodhimi : TMatrica;
i, j: integer;
begin
for i := 0 to 2 do // per secilin rresht
begin
for j := 0 to 2 do // per secilen kolone
begin
prodhimi[i,j] := 0;
for x := 0 to 2 do
prodhimi[i,j] := prodhimi[i,j] + A[x,i] * B[j,x]; // shumzo rreshtat me shtylla
end;
end;
result := prodhimi;
end;
Nese ke probleme lajmerohu
Krijoni Kontakt