Minggu, 04 Maret 2012

TUGAS
1. Buat program untuk perkalian 2 matrik!

uses wincrt;
var
   a,b,c : array [1..5,1..5] of integer;
   i,j,k,x,y,z : integer;
begin
   
     clrscr;   
     writeln('Selamat datang di program perkalian 2 matriks');
     writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
     writeln('----------------------------------------');
     writeln ('nama :yeni hidayana');
     writeln('Ukuran matrix A');
     write('Baris : '); readln(x);
     write('Kolom : '); readln(y);
     writeln;
     writeln('Ukuran matrix B');
     writeln('Baris : ',y);
     write('Kolom : '); readln(z);
     writeln('----------------------------------------');
     for i:=1 to x do
     for j:=1 to y do
     begin
          write('Elemen A[',i,',',j,'] : ');
          readln(a[i,j]);
     end;
     writeln;
     for i:=1 to y do
     for j:=1 to z do
     begin
          write('Elemen B[',i,',',j,'] : ');
          readln(b[i,j]);
     end;
     for i:=1 to x do
     for j:=1 to z do
     for k:=1 to y 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 x do
     begin
          for j:=1 to z do
          write(c[i,j]:4);
     writeln;
     end;
     writeln;
     readln;
end.

Hasil :


2. buat program untuk menampilkan matrik
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0

program matrik_identitas_yenihidayana;
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 mat[x,y]:=1;
write (mat[x,y]:3);
end;
writeln;
end;
end.

Hasil :


Tidak ada komentar:

Posting Komentar