program matrik_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.
---------------------------------------------------------
program invers_matrik;
uses wincrt;
var x:array[1..10,1..10] of integer; adj:array[1..10,1..10] of integer;
i,j:integer;
det:real;
begin
for i:=1 to 2 do
for j:=1 to 2 do
readln(x[i,j]);
clrscr;
writeln('matirk');
for i:=1 to 2 do
begin
for j:=1 to 2 do
write(x[i,j],' ');
writeln;
end;
writeln('<==================>');
writeln('determinan');
det:=x[1,1]*x[2,2]-x[1,2]*x[2,1];
write(det);
writeln;
writeln('<==================>');
writeln('adjoint');
adj[1,1]:=x[2,2];
adj[1,2]:=-x[1,2];
adj[2,1]:=-x[2,1];
adj[2,2]:=x[1,1];
for i:=1 to 2 do
begin
for j:=1 to 2 do
write(adj[i,j]:2,' ');
writeln;
end;
writeln('<=================>');
writeln('invers');
for i:=1 to 2 do
begin
for j:=1 to 2 do
write(adj[i,j]/det:4:2,' ');
writeln; end;
end.