Semester 2D
Tugas 1 :
- Buat Program Untuk Perkalian Dua Matrix
- Buat Program Untuk Menampilkan Matrix Identitas Terbalik
Program
Perkalian_2_Matrix_Rodikya;
useswincrt;
var
a,b,c : array [1..10,1..10] of integer;
i,j,k,x,y,z : integer;
begin
writeln('PROGRAM
PERKALIAN MATRIX');writeln;
writeln('ORDO MATRIX A');
write('Jumlah Baris : '); readln(x);
write('Jumlah Kolom : '); readln(y);
writeln;
writeln('ORDO MATRIX B');
writeln('Jumlah Baris : ',y);
write('Jumlah Kolom : '); readln(z);
writeln;
writeln
('MATRIX A');
for
i:=1 to x dofor j:=1 to y do
begin
write('Nilai Matrix A Baris ',i,', Kolom ',j,' : ');readln(a[i,j]);
end;
writeln ('MATRIX B');
for i:=1 to y do
for j:=1 to z do
begin
write('Nilai Matrix B Baris ',i,', Kolom ',j,' : '); readln(b[i,j]);
end;
for
i:=1 to x do
for
j:=1 to z dofor k:=1 to y do
c[i,j] := c[i,j] + a[i,k]*b[k,j];
writeln;
writeln('HASIL
PERKALIAN MATRIX ADALAH : ');
writeln;for i:=1 to x do
begin
for j:=1 to z do
write(c[i,j]:4);
writeln;
writeln;
end;
end.
No. 2 :
Program Matrik_Identitas_Rodikya;
useswincrt;
var
a,b,c:array[1..5,1..5] of integer;
x,y: integer;
for x:= 1 to 5 do
begin
for y:= 1 to 5 do
begin
a[x,y]:=0;
if x+y=6 then c[x,y]:=1;
write (c[x,y]:4);
end;
writeln;
end;
end.
Tidak ada komentar:
Posting Komentar