Tuesday, May 3, 2011

UTS

program UTS;
uses crt;
var
   i,j,k,brs_a,brs_b,klm_a,klm_b : integer;
   mat_a,mat_b,mat_c : array [1..50,1..50] of integer;

procedure input_matrik;
begin
writeln('INPUT MATRIK A :');
write('JUMLAH BARIS MATRIK A : '); readln(brs_a);
write('JUMLAH KOLOM MATRIK A : '); readln(klm_a);
writeln;
for i:=1 to brs_a do
    for j:=1 to klm_a do
    begin
        write('A[',i,',',j,'] =');
        readln(mat_a[i,j]);
    end;
writeln;

writeln('INPUT MATRIK B :');
write('JUMLAH BARIS MATRIK B : '); readln(brs_b);
write('JUMLAH BARIS MATRIK B : '); readln(klm_b);
writeln;
for i:=1 to brs_b do
    for j:=1 to klm_b do
    begin
         write('B[',i,',',j,'] =');
         readln(mat_b[i,j]);
    end;
writeln;
end;

procedure perkalian_matrik;
begin
writeln('PROSES PERKALIAN MATRIK');
for i:=1 to brs_a do
    for j:=1 to klm_b do
    begin
    mat_c[i,j]:= 0;
    for k:=1 to klm_a do
        mat_c[i,j]:= mat_c[i,j] + mat_a[i,k] * mat_b[k,j];
    end;
writeln;

writeln('MATRIK A :');
for i:=1 to brs_a do
begin
     for j:=1 to klm_a do
         write(mat_a[i,j]:4);
         writeln;
end;
writeln;

writeln('MATRIK B :');
for i:=1 to brs_b do
begin
     for j:=1 to klm_b do
         write(mat_b[i,j]:4);
         writeln;
end;
writeln;

writeln('MATRIK C :');
for i:=1 to brs_a do
begin
     for j:=1 to klm_b do
         write(mat_c[i,j]:4);
         writeln;
end;
end;

begin
clrscr;
input_matrik;
writeln('TEKAN "ENTER" UNTUK MELIHAT HASILNYA');
readln;
perkalian_matrik;
readln;
end.


0 komentar:

Post a Comment

Tinggalkan Komentar Disini