Matriks Identitas, simetris dan determinan matriks

Posted: 10 Mei 2010 in Algoritma Pemrograman

>Program Matriks Identitas, simetris dan determinan matriks dengan pascal:

Program Matriks;
uses wincrt;
type
data = array[1..20,1..20] of integer;
var
matrik : data;
pos : array[1..20] of integer;
neg : array[1..20] of integer;
i,j : integer;
barkom,pil : integer;
procedure identitas;
begin
writeln(‘ Penentuan ORDO MATRIKS (N x N)’);
write(‘Masukkan ordo matrik = ‘);readln(barkom);
clrscr;
for i:=1 to barkom do
for j:=1 to barkom do
begin
if i=j then
begin
gotoxy(j*5,i*3);
writeln(‘1’);
end
else
begin
gotoxy(j*5,i*3);
writeln(‘0’);
end;
end;
end;

procedure simetri;
var a: integer;
begin
Randomize;
writeln(‘ Penentuan ORDO MATRIKS (N x N)’);
write(‘masukkan ordo matrik = ‘);read(barkom);
clrscr;
for i :=1 to barkom do
for j :=1 to barkom do
matrik[i,j]:=-1;

for i :=1 to barkom do
for j :=1 to barkom do
begin
a := Random(10);
if matrik[i,j]=-1 then
begin
matrik[i,j]:=a;
matrik[j,i]:=matrik[i,j];
gotoxy(j*5,i*3);
writeln(matrik[i,j]);
end
else
begin
matrik[i,j]:=matrik[i,j];
gotoxy(j*5,i*3);
writeln(matrik[i,j]);
end;
end;
end;

procedure determinan;
var idx,k,l,deter : integer;
begin
writeln(‘Penentuan ORDO MATRIKS (N x N)’);
write(‘Masukkan ordo matrik = ‘);readln(barkom);
clrscr;
deter:=0;
for i:=1 to barkom do
for j:=1 to barkom do
begin
gotoxy(j*5,i*3);
readln(matrik[i,j]);
end;
if barkom=2 then
begin
deter:=(matrik[1,1]*matrik[2,2])-(matrik[1,2]*matrik[2,1]);
end
else

{inisialisasi nilai perkalian}
for idx:=1 to barkom do
begin
pos[idx]:=1;
neg[idx]:=1;
end;
{perkalian positif}

for l:=1 to barkom do
begin
idx:=l;
for k:=1 to barkom do
begin
pos[idx]:=pos[idx]*matrik[k,l];
l:=l+1;
if l>barkom then
begin
l:=1;
end;
end;
end;

{perkalian negatif}
for l:=1 to barkom do
begin
idx:=l;
for k:=1 to barkom do
begin
neg[idx]:=neg[idx]*matrik[k,l];
l:=l-1;
if l<1 then
l:=barkom;
end;
end;

{hitung hasil}
for idx:=1 to barkom do
begin
deter:=deter+pos[idx]-neg[idx];
end;
write(”);
write(‘determinan = ‘,deter);
end;

begin
writeln(‘ M E N U’);
writeln(‘(1) Membuat Matriks Identitas’);
writeln(‘(2) Membuat Matriks Simetri’);
writeln(‘(3) Melakukan Operasi Determinan Matriks’);
write(‘Pilihan (1-3)= ‘);readln(pil);
case pil of
1 : begin
identitas;
end;
2 : begin
simetri;
end;
3 : begin
determinan;
end;
else
writeln(‘inputan salah!!!’);
end;
end.


syntax pascal klik disini.

Komentar
  1. Anonymous mengatakan:

    >sangat membantu tugas kuliah..hhetrimakasih banyak. . .

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s