Sabtu, 03 Maret 2012

Tugas 1

PERTEMUAN KE 2 TANGGAL 29 FEBRUARI 2012
SEMESTER 2D
TUGAS 1 :
  • Buat Program Untuk Perkalian Dua Matrix
  • Buat Program Untuk Menampilkan Matrix Identitas Terbalik

 1. Perkalian 2 Matrix

PROGRAM PERKALIAN2_MATRIX;
USES WINCRT;

VAR
A,B,C : ARRAY [1..10,1..10] OF INTEGER;
O,P,Q,X,Y,R : INTEGER;


BEGIN
WRITELN('PROGRAM PERKALIAN 2 MATRIX');
WRITELN;
WRITELN('UKURAN Matrix A');
WRITE('Baris : '); READLN(X);
WRITE('kolom : '); READLN(Y);
CLRSCR;
WRITELN('UKURAN  Matrix B');
WRITELN('Baris : ',Y);
WRITE  ('kolom : '); READLN(R);
CLRSCR;
WRITELN ('Masukkan data Matrix A');
FOR O:=1 TO x DO
FOR P:=1 TO y DO
BEGIN
WRITE('A[',O,',',P,'] : ');READLN(A[O,P]);
END;

WRITELN;
WRITELN ('Masukkan data Matrix B');
FOR O:=1 TO Y do
FOR P:=1 TO R do
BEGIN
WRITE('B[',O,',',P,'] : '); READLN(B[O,P]);
END;

FOR O:=1 TO X DO
FOR P:=1 TO R DO
FOR Q:=1 TO Y DO
C[O,P] := C[O,P] + A[O,Q]*B[Q,P];
WRITELN;
WRITELN;

WRITELN('Hasil dari perkalian Matrix A dan Matrix B : ');
WRITELN;
FOR O:=1 TO X DO
BEGIN
FOR P:=1 TO R DO
WRITE(C[O,P],' ');
WRITELN;
END;
END.

 




2. Martix Identitas Terbalik
 program MATRIK_IDENTITAS_TERBALIK;

   uses WINCRT;
   var
   A,B,C : ARRAY[1..10,1..10] of INTEGER;
   X,Y,KOL,BAR : INTEGER;

   BEGIN
   FOR X := 1 TO 5 DO
   BEGIN
   FOR Y := 1 TO 5 DO
   BEGIN
   c[X,Y] :=0;
   IF X+Y=6 THEN C[X,Y]:=1;
   WRITE (C[X,Y]:4);
   END;
   WRITELN;
   END;
   END.

 

Tidak ada komentar:

Posting Komentar