program Perkalian_Matrix;
uses wincrt;
var
a,b,c : array [1..5,1..5] of integer;
i,j,k,n,m,p : integer;
begin
clrscr;
writeln('Selamat datang di program matriks..!!');
writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
writeln('Ukuran matrix A');
write('Baris : '); readln(n);
write('Kolom : '); readln(m);
writeln;
writeln('Ukuran matrix B');
writeln('Baris : ',m);
write('Kolom : '); readln(p);
for i:=1 to n do
for j:=1 to m do
begin
write('Elemen A[',i,',',j,'] : ');
readln(a[i,j]);
end;
writeln;
for i:=1 to m do
for j:=1 to p do
begin
write('Elemen B[',i,',',j,'] : ');
readln(b[i,j]);
end;
for i:=1 to n do
for j:=1 to p do
for k:=1 to m do
c[i,j] := c[i,j] + a[i,k]*b[k,j];
writeln('----------------------------------------');
writeln('Hasil dari perkalian Matrix A dengan Matrix B adalah : ');
Writeln;
for i:=1 to n do
begin
for j:=1 to p do
write(c[i,j]:4);
writeln;
end;
writeln;
readln;
end.
uses wincrt;
var
a,b,c : array [1..5,1..5] of integer;
i,j,k,n,m,p : integer;
begin
clrscr;
writeln('Selamat datang di program matriks..!!');
writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
writeln('Ukuran matrix A');
write('Baris : '); readln(n);
write('Kolom : '); readln(m);
writeln;
writeln('Ukuran matrix B');
writeln('Baris : ',m);
write('Kolom : '); readln(p);
for i:=1 to n do
for j:=1 to m do
begin
write('Elemen A[',i,',',j,'] : ');
readln(a[i,j]);
end;
writeln;
for i:=1 to m do
for j:=1 to p do
begin
write('Elemen B[',i,',',j,'] : ');
readln(b[i,j]);
end;
for i:=1 to n do
for j:=1 to p do
for k:=1 to m do
c[i,j] := c[i,j] + a[i,k]*b[k,j];
writeln('----------------------------------------');
writeln('Hasil dari perkalian Matrix A dengan Matrix B adalah : ');
Writeln;
for i:=1 to n do
begin
for j:=1 to p do
write(c[i,j]:4);
writeln;
end;
writeln;
readln;
end.
Tampilan output :
Jawaban -2 ("Reverse" - Matrik Identitas)
program identitas;
uses wincrt;
var
a,b,c:array [1..10,1..10] of integer;
x,y,kol,bar:integer;
begin
for x:= 1 to 5 do
begin for y:=1 to 5 do
begin
c[x,y]:=0;
if x+y=6 then c[x,y]:=1;
write(c[x,y]:4);
end;
writeln;
end;
end.
Tampilan Output :
Tidak ada komentar:
Posting Komentar