02 February 2013

Program Perkalian Matrix Dengan Pascal+Lengkap



uses wincrt;
Type matriks    = array[1..10,1..10] of integer;
var a,b,c,d     : matriks; baris,kolom,barisA,kolomA,kolomB,i,j,k      : integer;
Procedure Input_data (var data: matriks;baris,kolom:integer);
Begin
     For i:= 1 to baris do
     for j:= 1 to kolom do
         Begin
              write('Data  : ');
              readln(data[i,j]);
         end
end;
Procedure Cetak_data (data:matriks;baris,kolom:integer);
Begin
     For i:= 1 to baris do
     Begin
     write('[');
          for j:= 1 to kolom do
          write(data[i,j]:4);
     write(']');
     writeln;
     end
end;
Procedure Kali (var c:matriks;barisA,kolomA,kolomB:integer);
Begin
     for i:= 1 to barisA do
     for j:= 1 to kolomB do
     begin
          c[i,j]:=0;
          for k:= 1 to kolomA do
          c[i,j]:=c[i,j]+(a[i,k]*b[k,j]);
     end;
end;
Begin
     Write('Baris A: '); readln(barisA);
     write('Kolom A/Baris B: '); readln(kolomA);
     Write('Kolom B: '); readln(kolomB);
     writeln;
     Writeln('DATA Matriks A : ');
     Input_data(a,barisA,kolomA);
     writeln;
     Writeln('DATA Matriks B : ');
     Input_data(b,kolomA,kolomB);
     writeln('MATRIKS A');
     Kali(c,barisA,kolomA,kolomB);
     Cetak_data (a,barisA,kolomA);
     writeln('MATRIKS B');
     Cetak_data (b,kolomA,kolomB);
     writeln('HASIL PERKALIAN');
     Cetak_data (c,barisA,kolomB);
     readln
end.



3 comments:

Please double post in this blog is up to you

SILAHKAN COPY PASTE SEPUAS MU

Related Posts Plugin for WordPress, Blogger...