Jumat, 09 Desember 2011

Program Perkalian Matriks...

Berikut adalah beberapa program yang telah berhasil aku dapatkan,,
semoga bermanfaat......

# program Matriks Penjumlahan, Pengurangan, dan Perkalian
program matrik_penjumlahan_pengurangan_perkalian;
uses wincrt;
var a,b,c: array[1..10,1..10] of integer;
i,j,k1,k2,b1,b2,sum,r:integer;

begin
write('Masukkan baris Matrik A = ');readln(b1);
write('Masukkan kolom Matrik A = ');readln(k1);
write('Masukkan baris Matrik B = ');readln(b2);
write('Masukkan kolom Matrik B = ');readln(k2);
for i:=1 to b1 do
for j:=1 to k1 do
readln(a[i,j]);
writeln;
for i:=1 to b2 do
for j:=1 to k2 do
readln(b[i,j]);
writeln;
writeln('Matrik A');
writeln('==================');
for i:=1 to b1 do
begin
for j:=1 to k1 do
write(a[i,j],' ');
writeln;
end;
writeln;
writeln('Matrik B');
writeln('===================');
for i:=1 to b2 do
begin
for j:=1 to k2 do
write(b[i,j],' ');
writeln;

end;
writeln;
writeln('Matrik A*B');
writeln('================');
for i:=1 to b1 do
begin
for j:=1 to k2 do
begin
sum:=0;
for r:=1 to k1 do
sum:=sum+a[i,r]*b[r,j];
c[i,j]:=sum;
write(c[i,j]:2,' ');
end;
writeln;
end;
end.

sehingga bila dimasukkan di program TPW akan terlihat seperti berikut.


 dan setelah di run akan terlihat hasilnya sebagai berikut.

Leave a Reply

 
 
Free Bounce Cursors at www.totallyfreecursors.com