Sabtu, 17 Januari 2009

Membuat Program Perkalian Matriks

program Perkalian_Matriks;
uses wincrt;
var
a,b,c:array[1..4,1..4] of integer;
i,j,x,y:integer;
begin
clrscr;
begin
writeln(' Matriks I ');
for i:= 1 to 4 do
begin
for j:= 1 to 4 do
begin
write(' Masukkan bilangan untuk baris ke-',i,' kolom ke-',j,': '); readln(a[i,j]);
end;
writeln;
end;
end;
begin
writeln;
writeln(' Matriks I ');
writeln;
for i:= 1 to 4 do
begin
for j:= 1 to 4 do
begin
write(a[i,j]:7);
end;
writeln;
writeln;
end;
writeln;
writeln;
end;
begin
writeln(' Matriks II ');
for x:= 1 to 4 do
begin
for y:=1 to 4 do
begin
write(' Masukkan bilangan untuk baris ke-',x,' kolom ke ',y,': '); readln(b[x,y]);
end;
writeln;
end;
end;
begin
writeln;
writeln(' Matriks II ');
writeln;
for x:= 1 to 4 do
begin
for y:= 1 to 4 do
begin
write(b[x,y]:7);
end;
writeln;
writeln;
end;
writeln;
writeln;
end;
begin
writeln(' Tekan Enter Untuk Melihat Hasil Operasi dari Matriks I X Matriks II ');readln;
writeln(' M I x M II ');
writeln;
for i:=1 to 4 do
begin
for y:=1 to 4 do
begin
c[i,y]:=0;
for x:=1 to 4 do
begin
c[i,y]:=c[i,y]+a[i,x]*b[x,y];
write(' Elemen ke (',i,',',y,') = ',c[i,y]);
end;
end;
writeln;
end;
end;
writeln;
begin
writeln(' Matriks Hasil ');
writeln;
for i:=1 to 4 do
begin
for y:=1 to 4 do
write(c[i,y]:7);
writeln;
writeln;
end;
writeln;
writeln;
end;
writeln;
readln;
end.

Tidak ada komentar:

Posting Komentar

Kirim Komentar Anda
(Send Your Comment)