program kali_matrik;
uses wincrt;
const
barisA =2;
kolomA =2;
barisB =2;
kolomB =2;
type
matrikA = array [1..barisA, 1..kolomA] of integer;
matrikB = array [1..barisB, 1..kolomB] of integer;
matrikC = array [ 1..2, 1..2 ] of integer;
var
A: matrikA;
B: matrikB;
C: matrikC;
i,j,k : integer;
begin
writeln (‘ isi matrik A ‘);
for i:= 1 to barisA do begin
for j:= 1 to kolomA do begin
write (‘A[',i,',',j,']=’); readln (A[i,j]);
end;
end;
writeln (‘ isi matrik B’);
for i:= 1 to barisB do begin
for j:= 1 to kolomB do begin
write (‘A[',i,',',j,']=’); readln (B[i,j]);
end;
end;
{mengalikan matrik}
for i:= 1 to barisA do begin
for j:= 1 to barisb do begin
for k:= 1 to barisB do begin
C[i,j]:= C[i,j]+A[i,k]* B[k,j];
end;
end;
end;
{menampilkan hasil}
writeln (‘hasil A * B’);
for i:= 1 to 2 do begin
for j:= 1 to 2 do begin
writeln (‘ C[',i,',',j,']=’,C[i,j]);
end;
end;
end.
0 comments:
Post a Comment