Berikut ini adalah source codenya :
type data = array[1..10,1..10] of integer;
var matriksI,matriksII : data;
baris,kolom : integer;
procedure IsiMatriks;
var i,j : integer;
begin
writeln('Penentuan ORDO MATRIKS I');
write('Masukkan banyak baris matriks I = ');readln(baris);
write('Masukkan banyak kolom matriks I = ');readln(kolom);
for i:=1 to baris do
for j:=1 to kolom do
begin
gotoxy(j*10,i*5);
readln(matriksI[i,j]);
end;
clrscr;
writeln('Penentuan ORDO MATRIKS II');
write('Masukkan banyak baris matriks II = ');readln(baris);
write('Masukkan banyak kolom matriks II = ');readln(kolom);
for i:=1 to baris do
for j:=1 to kolom do
begin
gotoxy(j*10,i*5);
readln(matriksII[i,j]);
end;
end;
procedure KaliMatriks(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]+matriksI[i,z]*matriksII[z,j];
end;
clrscr;
writeln('Hasil Perkalian Matriks'); writeln;
for i:=1 to baris do
for j:=1 to kolom do
begin
gotoxy(j*7,i*3);
write(hasil[i,j]);
end;
end;
{* PROGRAM UTAMA *}
begin
IsiMatriks;
KaliMatriks(matriksI,matriksII);
end.
0 komentar:
Posting Komentar