usescrt;
type t=object
m1,m2 : array [1..2,1..2] of integer;
lok : array [1..4] of integer;
procedure input;
proceduretampil;
procedure kali;
proceduredeterminan;
procedure transpose;
end;
var m : t;
i,j,k,pil,b,c : integer;
proceduret.input;
begin
clrscr;
writeln ('-----input matrik-----');
for i:= 1 to 2 do
begin
for j:=1 to 2 do
begin
write ('elemenmatrik [',i,',',j,']: ');
readln (m1[i,j]);
end;
end;
gotoxy (35,1); writeln('-------input matrik
II------');
k:=2;
fori := 1 to 2 do
begin
for j:= 1 to 2 do
begin
gotoxy(35,k);
inc (k);
write('elemenmatrik [',i,',',j,']: ');
readln(m2[i,j]);
end;
end;
end;
proceduret.tampil;
begin
writeln;
writeln (' Matrik I ');
writeln (m1[1,1]:5,m1[1,2]:5);
writeln (m1[2,1]:5,m1[2,2]:5);
gotoxy (35,7); writeln ('matrik II');
gotoxy (35,8); writeln (m2[1,1]:5,m2[1,2]:5);
gotoxy (35,9); writeln (m2[2,1]:5,m2[2,2]:5);
readln;
end;
proceduret.kali;
begin
gotoxy (26,12); writeln ('----
hasilperkalianmatrik----');
lok[1] := m1[1,1]*m2[1,1] + m1[1,2]*m2[2,1];
lok[2] := m1[1,1]*m2[1,2] + m1[1,2]*m2[2,2];
lok[3] := m1[2,1]*m2[1,1] + m1[2,2]*m2[2,1];
lok[4] := m1[2,1]*m2[1,2] + m1[2,2]*m2[2,2];
gotoxy (32,14); writeln (lok[1]:5,lok[2]:5);
gotoxy (32,16); writeln (lok[1]:5,lok[2]:5);
readln;
end;
proceduret.determinan;
begin
gotoxy (28,11); writeln('---determinanmatrik---');
writeln;
lok[1] := m1[1,1] * m1[2,2];
lok[2] := m1[1,2] * m1[2,1];
lok[3] := m2[1,1] * m2[2,2];
lok[4] := m2[1,2] * m2[2,1];
b := lok[1] - lok[2];
c := lok[3] - lok[4];
gotoxy (27,12); writeln (' determinanmatrik I : ',b);
gotoxy (27,14); writeln (' determinanmatrik II : ',c);
readln;
end;
proceduret.transpose;
begin
gotoxy (6,10);
writeln ('---hasil transpose matrik I--');
lok[1] := m1[1,1];
lok[2] := m1[2,1];
lok[3] := m1[1,2];
lok[4] := m1[2,2];
gotoxy (12,12); writeln(lok[1]:5,lok[2]:5);
gotoxy (12,13); writeln(lok[3]:5,lok[4]:5);
gotoxy (42,10); writeln('--hasil transpose matrik
II--');
lok[1] := m2[1,1];
lok[2] := m2[2,1];
lok[3] := m2[1,2];
lok[4] := m2[2,2];
gotoxy (49,12); writeln(lok[1]:5,lok[2]:5);
gotoxy (49,13); writeln(lok[3]:5,lok[4]:5);
readln;
end;
begin
repeat
clrscr;
gotoxy (25,1); writeln ('------menu matrik ------');
gotoxy (25,2); writeln ('1. input matrik ');
gotoxy (25,3); writeln ('2. perkalianmatrik ');
gotoxy (25,4); writeln ('3. determinanmatrik ');
gotoxy (25,5); writeln ('4. transpose matrik ');
gotoxy (25,6); writeln ('5. keluar ');
gotoxy (25,7); writeln ('========================');
gotoxy (25,8); write ('pilihan [1..5] : ');
readln(pil);
casepil of
1 : begin
m.input;
m.tampil;
end;
2: m.kali;
3:
m.determinan;
4:
m.transpose;
end;
until (pil) = 5;
end.
Tampilan menu yang akan dihasilkan seperti di bawah ini :
Untuk pilihan pertama gunanya untuk membuat matriks dengan menginput angka angka elemen matriks yang kita inginkan :
Pilihan Kedua gunannya untuk menghasilkan proses perkalian dari matriks yang kita input.
Dan pilihan yang ketiga berguna untuk melalukakn proses determinannya.
Pilihan Keempat yaitu untuk mentranspose matriks
0 komentar:
Posting Komentar