TUGAS 1
SOAL : BUAT PROGRAM UNTUK PERKALIAN 2 MATRIK
JAWABAN :
program Perkalian_Matrix;
uses wincrt;
var
a,b,c : array [1..5,1..5] of integer;
i,j,k,x,y,z : integer;
begin
clrscr;
writeln('Selamat datang di program perkalian 2 matriks');
writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
writeln('----------------------------------------');
writeln ('nama :venus salmah');
writeln('Ukuran matrix A');
write('Baris : '); readln(x);
write('Kolom : '); readln(y);
writeln;
writeln('Ukuran matrix B');
writeln('Baris : ',y);
write('Kolom : '); readln(z);
writeln('----------------------------------------');
for i:=1 to x do
for j:=1 to y do
begin
write('Elemen A[',i,',',j,'] : ');
readln(a[i,j]);
end;
writeln;
for i:=1 to y do
for j:=1 to z do
begin
write('Elemen B[',i,',',j,'] : ');
readln(b[i,j]);
end;
for i:=1 to x do
for j:=1 to z do
for k:=1 to y 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 x do
begin
for j:=1 to z do
write(c[i,j]:4);
writeln;
end;
writeln;
readln;
end.
INILAH HASIL GAMBAR DARI SCRIPT DI ATAS
TUGAS 2 :
SOAL : BUAT PROGRAM UNTUK MENAMPILKAN MATRIKS
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0
JAWABAN :
program matrik_identitas_venussalmah;
uses WinCrt;
var
mat:array[1..5,1..5]of integer;
x,y:integer;
begin
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
mat[x,y]:=0;
if x+y=6 then mat[x,y]:=1;
write (mat[x,y]:3);
end;
writeln;
end;
end.
INILAH HASIL GAMBAR DARI SRIPT DI ATAS
Tidak ada komentar:
Posting Komentar