Array Pascal

uses crt;
type
larik=array[1..25,1..25] of real;
var
I,J,K:byte;
M,N,L:byte;
A,B,C:larik;
begin
clrscr;

write('Baris Matrik Pertama ? ');readln(M);
write('Kolom Matrik Pertama / Baris Matrik Kedua ?');readln(N);
write('KOlom Matrik ke dua ? ');readln(L);

writeln('Matrik yang pertama: ');
for I:= 1 to M do
Begin
for J:= 1 to N do
begin
write('Nilai[',I,',',J,']?');readln(A[I,J]);
end;
writeln;
end;
writeln('Matrik yang Kedua');
for I:=1 to N do
begin
for J:=1 to L do
begin
write('Nilai[',I,',',J,']?');readln(B[I,J]);
end;
writeln;
end;

for I := 1 to M do
begin
for J:=1 to N do
begin
C[I,J]:=0;
for K:=1 to L do
C[I,J]:=C[I,J]+A[I,K]*B[K,J]
end;
end;

writeln('Hasil dari Perkalian Matrik : ');
writeln;

for I:=1 to M do
begin
for J:=1 to L do
write(C[I,J]:9:2);
writeln;
readln;
end;
end.

0 komentar: