PERTEMUAN KE 2 TANGGAL 29 FEBRUARI 2012
SEMESTER 2D
TUGAS 1 :
- Buat Program Untuk Perkalian Dua Matrix
- Buat Program Untuk Menampilkan Matrix Identitas Terbalik
- Program Pascal Untuk Menghitung Perkalian Dua Matrix
PROGRAM MULTIPLICATION_OF_TWO_MATRIX;
USES WINCRT;
VAR
A,B,C : ARRAY [1..10,1..10] OF INTEGER;
I,J,K,X,Y,Z : INTEGER;
BEGIN
WRITELN('MULTIPLICATION PROGRAM OF TWO MATRIX');
WRITELN;
WRITELN('Ordo Of Matrix A');
WRITE('Row : '); READLN(X);
WRITE('Column : '); READLN(Y);
CLRSCR;
WRITELN('Ordo Of Matrix B');
WRITELN('Row : ',Y);
WRITE('Collumn : '); READLN(Z);
CLRSCR;
WRITELN ('Input Elemens of Matrix A');
FOR I:=1 TO x DO
FOR j:=1 TO y DO
BEGIN
WRITE('A[',i,',',j,'] : ');READLN(A[I,J]);
END;
WRITELN;
WRITELN ('Input Elemens of Matrix B');
FOR I:=1 TO Y do
FOR J:=1 TO Z do
BEGIN
WRITE('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;
WRITELN('Result Of Multiplication Matrix A and Matrix B : ');
WRITELN;
FOR I:=1 TO X DO
BEGIN
FOR J:=1 TO Z DO
WRITE(C[I,J],' ');
WRITELN;
END;
END.
1.2 Layout Program
PROGRAM MATRIX;
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.
2.2 Layout Program
Tidak ada komentar:
Posting Komentar