Sabtu, 03 Maret 2012

Tugase P. Hedi Yadika Perkalian

Program Perkalian_Matriks;
uses wincrt;
var
c,d,h:array[1..10,1..10] of integer;
b1,k1,x1,y1,a,b2,k2,x2,y2:longint;
begin;

write('masukkan jumlah baris  1: '); readln(b1);
write('masukkan jumlah kolom  1: '); readln(k1);
for x1:= 1 to b1 do
begin
for y1:= 1 to k1 do
begin
write('[',x1,':',y1,']='); readln(c[x1,y1]);
end;
end;


write('masukkan jumlah baris  2: '); readln(b2);
write('masukkan jumlah kolom  2: '); readln(k2);
for x2:= 1 to b2 do
begin
for y2:=1 to k2 do
begin
write('[',x2,':',y2,']='); readln(d[x2,y2]);
end;
end;

if k1=x2 then begin
writeln('Hasilnya adalah');
for x1:= 1 to b1 do
begin
for a:=1 to k2 do
begin
for y1:= 1 to k1 do
begin
for y2:= a to k2 do
begin
for x2:=y1 to b2 do
begin
h[x1,y2]:=h[x1,y2]+c[x1,y1]*d[x2,y2];
if k1=y1 then
begin
write(h[x1,y2]:7);
end;
x2:=b2;
end;
y2:=k2;
end;
end;
end;
writeln;
end;
end else
begin
writeln('Maaf operasi perkalian matriks tidak bisa dikerjakan !!!');
writeln('karena kolom matriks1 !!! (',k1,' kolom) tidak sama dengan baris matriks 2 !!!(',x2,' baris)');
end;
end.

Tidak ada komentar:

Posting Komentar