PROGRAM PERKALIAN MATRIKS
program matrik;
uses wincrt;
type data = array[1..10,1..10] of integer;
var matrikI,matrikII : data;
baris,kolom,pil : integer;
procedure isimatrik;
var i,j : integer;
begin
writeln('Penentuan ORDO MATRIK I');
write('Masukan banyak baris matrik I = '); readln(baris);
write('Masukan banyak kolom matrik I = '); readln(kolom);
for i:=1 to baris do
for j:=1 to kolom do
begin
write('matriks A ',i,',',j,': ');
readln(matrikI[i,j]);
end;
writeln('Penentuan ORDO MATRIK II');
write('Masukan banyak baris matrik II = '); readln(baris);
write('Masukan banyak kolom matrik II = '); readln(kolom);
for i:=1 to baris do
for j:=1 to kolom do
begin
write('matriks B ',i,',',j,': '); readln(matrikII[i,j]);
end;
end;
procedure kalimatrik(m1,m2 : data);
var hasil : data;
i,j,z : integer;
begin
for i:=1 to baris do
for j:=1 to kolom do
begin
hasil[i,j]:=0;
for z:=1 to baris do
hasil[i,j]:=hasil[i,j]+matrikI[i,z]*matrikII[z,j];
end;
writeln;
writeln;
writeln('Hasil perkalian Matriks A dan Matriks B: ');
writeln;
writeln('Matriks A');
writeln('------------->>');
for i:= 1 to baris do
begin
for j:=1 to kolom do
write(matrikI[i,j],' ');
writeln;
writeln;
end;
writeln;
writeln('Matriks B');
writeln('------------->>');
for i:=1 to baris do
begin
for j:= 1 to kolom do
write(matrikII[i,j],' ');
writeln;
writeln;
end;
writeln;
writeln('Hasil perkalian MATRIK');
writeln;
for i:=1 to baris do
begin
for j:=1 to kolom do
write(hasil[i,j],' ');
writeln;
writeln;
writeln;
end;
writeln;
end;
begin
isimatrik;
kalimatrik(matrikI,matrikII);
end.
0 komentar:
Post a Comment