oleh :
arif zainurrohman
type t = object
m1,m2 : array [1..3,1..3] of integer;
lok:array[1..9]of integer;
procedure input;
procedure tampil;
procedure tambah;
procedure kurang;
procedure deter;
procedure transpos;
end;
var m:t;
i,j,k,pil,det1,det2:integer;
procedure t.input;
begin
clrscr;
writeln('Input Matrik I');
for i := 1 to 3 do
begin
for j := 1 to 3 do
begin
write('Elemen Matrik [',i,',',j,'] : ');
readln(m1[i,j]);
end;
end;
gotoxy(35,1);
writeln('Input Matrik II');k:=2;
for i := 1 to 3 do
begin
for j := 1 to 3 do
begin
gotoxy(35,k);inc(k);
write('Elemen Matrik [',i,',',j,'] : ');
readln(m2[i,j]);
end;
end;
end;
procedure t.tampil;
begin
writeln;
writeln(' Matrik I ');
writeln(' ');
writeln(m1[1,1]:5,m1[1,2]:5,m1[1,3]:5);
writeln(m1[2,1]:5,m1[2,2]:5,m1[2,3]:5);
writeln(m1[3,1]:5,m1[3,2]:5,m1[3,3]:5);
gotoxy(35,12);writeln(' Matrik II ');
gotoxy(35,14);writeln(m2[1,1]:5,m2[1,2]:5,m2[1,3]:5);
gotoxy(35,15);writeln(m2[2,1]:5,m2[2,2]:5,m2[2,3]:5);
gotoxy(35,16);writeln(m2[3,1]:5,m2[3,2]:5,m2[3,3]:5);
readln;
end;
procedure t.deter;
begin
writeln;
writeln(' Matrik I ');
writeln(' ');
writeln(m1[1,1]:5,m1[1,2]:5,m1[1,3]:5 , '|' , m1[1,1]:5,m1[1,2]:5);
writeln(m1[2,1]:5,m1[2,2]:5,m1[2,3]:5 , '|' , m1[2,1]:5,m1[2,2]:5);
writeln(m1[3,1]:5,m1[3,2]:5,m1[3,3]:5 , '|' , m1[3,1]:5,m1[3,2]:5);
gotoxy(35,2);writeln(' Matrik II ');
gotoxy(35,4);writeln(m2[1,1]:5,m2[1,2]:5,m2[1,3]:5 , '|' , m2[1,1]:5,m2[1,2]:5);
gotoxy(35,5);writeln(m2[2,1]:5,m2[2,2]:5,m2[2,3]:5 , '|' , m2[2,1]:5,m2[2,2]:5);
gotoxy(35,6);writeln(m2[3,1]:5,m2[3,2]:5,m2[3,3]:5 , '|' , m2[3,1]:5,m2[3,2]:5);
writeln;
det1:=(m1[1,1]*m1[2,2]*m1[3,3])+(m1[1,2]*m1[2,3]*m1[3,1])+(m1[1,3]*m1[2,1]*m1[3,2])-(m1[3,1]*m1[2,2]*m1[1,3])-(m1[3,2]*m1[2,3]*m1[1,1])-(m1[3,1]*m1[2,1]*m1[1,2]);
det2:=(m2[1,1]*m2[2,2]*m2[3,3])+(m2[1,2]*m2[2,3]*m2[3,1])+(m2[1,3]*m2[2,1]*m2[3,2])-(m2[3,1]*m2[2,2]*m2[1,3])-(m2[3,2]*m2[2,3]*m2[1,1])-(m2[3,1]*m2[2,1]*m2[1,2]);
writeln;
writeln('Determinan Matrik I : ',det1);
writeln('Determinan Matrik II : ',det2);
readln;
end;
procedure t.tambah;
begin
writeln;
writeln(' Penjumlahan Matrik ');
writeln('---------------------------------------');
lok[1]:=(m1[1,1]+m2[1,1]);
lok[2]:=(m1[1,2]+m2[1,2]);
lok[3]:=(m1[1,3]+m2[1,3]);
lok[4]:=(m1[2,1]+m2[2,1]);
lok[5]:=(m1[2,2]+m2[2,2]);
lok[6]:=(m1[2,3]+m2[2,3]);
lok[7]:=(m1[3,1]+m2[3,1]);
lok[8]:=(m1[3,2]+m2[3,2]);
lok[9]:=(m1[3,3]+m2[3,3]);
writeln;
writeln(lok[1]:5,lok[2]:5,lok[3]:5);
writeln(lok[4]:5,lok[5]:5,lok[6]:5);
writeln(lok[7]:5,lok[8]:5,lok[9]:5);
readln;
end;
procedure t.kurang;
begin
writeln;
writeln(' Pengurangan Matrik ');
writeln('---------------------------------------');
lok[1]:=(m1[1,1]-m2[1,1]);
lok[2]:=(m1[1,2]-m2[1,2]);
lok[3]:=(m1[1,3]-m2[1,3]);
lok[4]:=(m1[2,1]-m2[2,1]);
lok[5]:=(m1[2,2]-m2[2,2]);
lok[6]:=(m1[2,3]-m2[2,3]);
lok[7]:=(m1[3,1]-m2[3,1]);
lok[8]:=(m1[3,2]-m2[3,2]);
lok[9]:=(m1[3,3]-m2[3,3]);
writeln;
writeln(lok[1]:5,lok[2]:5,lok[3]:5);
writeln(lok[4]:5,lok[5]:5,lok[6]:5);
writeln(lok[7]:5,lok[8]:5,lok[9]:5);
readln;
end;
procedure t.transpos;
begin
writeln;
writeln(' Transpose Matrik I ');
writeln(m1[1,1]:5,m1[2,1]:5,m1[3,1]:5);
writeln(m1[1,2]:5,m1[2,2]:5,m1[3,2]:5);
writeln(m1[1,3]:5,m1[2,3]:5,m1[3,3]:5);
gotoxy(35,2);writeln(' Transpose Matrik II ');
gotoxy(35,3);writeln(m2[1,1]:5,m2[2,1]:5,m2[3,1]:5);
gotoxy(35,4);writeln(m2[1,2]:5,m2[2,2]:5,m2[3,2]:5);
gotoxy(35,5);writeln(m2[1,3]:5,m2[2,3]:5,m2[3,3]:5);
readln;
end;
begin
repeat;
clrscr;
gotoxy(25,1);writeln(' *** Menu Matrik *** ');
gotoxy(25,2);writeln(' 1. Input Matrik ');
gotoxy(25,3);writeln(' 2. Transpose Matrik ');
gotoxy(25,4);writeln(' 3. Determinan Matrik ');
gotoxy(25,5);writeln(' 4. Penjumlahan Matrik ');
gotoxy(25,6);writeln(' 5. Pengurangan Matrik ');
gotoxy(25,7);writeln(' 6. Keluar ');
gotoxy(25,8);write(' Pilihan [1..6] : ');
readln(pil);
case pil of
1: begin
m.input;
m.tampil;
end;
2: begin
clrscr;
m.transpos;
end;
3: begin
clrscr;
m.deter;
end;
4: begin
clrscr;
m.tambah;
end;
5: begin
clrscr;
m.kurang;
end;
end;
until (pil = 6);
end.
Ibu Kota, 23 April 2015
akhukumfillah arifzainurrohman
0 komentar:
Posting Komentar