Diberdayakan oleh Blogger.
RSS

Aljabar Linier



      
     1.      Buatlah aljabar pemrograman perkalian pada matriks!
program x_mtrik;
uses crt;

var
matrikA : array[1..2, 1..3] of integer;
matrikB : array[1..3, 1..2] of integer;
matrikC : array[1..2, 1..2] of integer;

k,l,m : integer;

begin
clrscr;
writeln('Elemen Matrik A : ');
for k:=1 to 2 do
    begin
        for m:=1 to 3 do
        begin
        write('Baris-',k,'Kolom-',m,'=');
        readln(matrikA[k,m]);
    end;
end;

writeln;
writeln('Elemen Matrik B : ');

for m:=1 to 3 do
    begin
        for l:=1 to 2 do
        begin
        write('Baris-',m,'kolom-',l,'=');
        readln(matrikB[m,l]);
    end;
end;

for k:= 1 to 2 do
    begin
        for l:=1 to 2 do
        begin
        matrikC[k,l]:=0;
                for m:=1 to 3 do
                begin
                MatrikC[k,l]:=matrikC[k,l] + matrikA[k,m] * matrikB[m,l];
        end;
    end;
end;

writeln;
for k:=1 to 2 do
    begin
        for m:=1 to 3 do
        begin
        write(matrikA[k,m]:4);
    end;
    writeln;
end;

writeln('X');
for m:=1 to 3 do
    begin
        for l:=1 to 2 do
        begin
        write(matrikB[m,l]:4);
    end;
    writeln;
end;

writeln('=');
for k:=1 to 2 do
    begin
        for l:=1 to 2 do
        begin
        write(matrikC[k,l]:4);
    end;
    writeln;
end;

readln;
end.

      2.      Buatlah aljabar pemrograman determinan pada matriks!
program determinan;
uses wincrt;
var A : array[1..2,1..2] of integer;
j,k,D : integer;
begin
For j:=1 to 2 do
begin
write('Entrikan baris ',j,' matriks A : ');
readln(A[j,1] , A[j,2]);
end;
For j:=1 to 2 do
begin
For k:=1 to 2 do write(A[j,k] : 5);
writeln;
end;
writeln;writeln;writeln;
D := A[1,1]*A[2,2] - A[1,2]*A[2,1];
writeln('Det(A) = ',D);
end.

      3.      Buatlah aljabar pemrograman transpose pada matriks!
program transpose;
uses crt;
var
matriks:array[1..5,1..5] of integer;
i,j,k,l,t : integer;
label satu,dua,tiga;

begin
satu:
clrscr;
write ('___________PROGRAM TRANSPOSE ARRAY______________');
writeln;
writeln;
write('masukkan jumlah elemen baris yang diinginkan (2 ~ 5) : ');readln(k);
write('masukkan jumlah elemen kolom yang diinginkan (2 ~ 5) : ');readln(l);
if (k=0) or (l=0) then goto satu;
if (k+l<3) or (k+l>10) then goto satu;
writeln;
for i :=1 to k do
begin
for j :=1 to l do
begin
write('array ','[ ',i,',',j,' ]',' : ');readln(matriks[i,j]);
end;
end;
clrscr;
writeln('matriks sebelum mengalami transpose');
writeln;
for i:=1 to k do
begin
for j:=1 to l do
begin
write(matriks[i,j]:10);
if j=l then
begin
writeln;
writeln;
end;
end;
end;
writeln;
writeln('matriks yang sudah mengalami transpose');
writeln;
for i:=1 to l do
begin
for j:=1 to k do
begin
write(matriks[j,i]:10);
if j = k then
begin
writeln;
writeln;
end;
end;
end;
readln;
clrscr;
tiga:
write('ingin coba lagi?(1 ~ 0) ');readln(t);
if t = 1 then
goto satu
else if t = 0 then goto dua
else
goto tiga;
dua:
clrscr; 
write('application terminate');
delay(1000)
end.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar