Sabtu, 03 Maret 2012

program Perkalian_Matrix;
 uses wincrt;
 var
    a,b,c : array [1..5,1..5] of integer;
    i,j,k,n,m,p : integer;
 begin
      clrscr;
      writeln('Selamat datang di program matriks..!!');
      writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
      writeln('----------------------------------------');
      writeln('Ukuran matrix A');
      write('Baris : '); readln(n);
      write('Kolom : '); readln(m);
      writeln;
      writeln('Ukuran matrix B');
      writeln('Baris : ',m);
      write('Kolom : '); readln(p);
      writeln('----------------------------------------');
      for i:=1 to n do
      for j:=1 to m do
      begin
           write('Elemen A[',i,',',j,'] : ');
           readln(a[i,j]);
      end;
      writeln;
      for i:=1 to m do
      for j:=1 to p do
      begin
           write('Elemen B[',i,',',j,'] : ');
           readln(b[i,j]);
      end;
      for i:=1 to n do
      for j:=1 to p do
      for k:=1 to m do
      c[i,j] := c[i,j] + a[i,k]*b[k,j];
      writeln('----------------------------------------');
     writeln('Hasil dari perkalian Matrix A dengan Matrix B adalah : ');
     Writeln;
     for i:=1 to n do
     begin
          for j:=1 to p do
          write(c[i,j]:4);
     writeln;
     end;
      writeln;
      readln;
 end.





Jawaban Tugas (2) - MATRIKS IDENTITAS (Reverse)
  
program identitas_matrik;
uses WinCrt;
var
mat:array[1..5,1..5]of integer;
x,y:integer;
begin
  for x:=1 to 5 do
  begin
    for y:=1 to 5 do
    begin
      mat[x,y]:=0;
      if x+y=6 then matx,y]:=1;
      write (mat[x,y]:3);
    end;
   writeln;
  end;
end.









Tidak ada komentar:

Posting Komentar