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 PERKALIAN_MATRIX;
USES WINCRT;
VAR
A,B,C : ARRAY
[1..10,1..10] OF INTEGER;
I,J,K,X,Y,Z : INTEGER;
BEGIN
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;
WRITELN ('Elemen Matrix A');
FOR I:=1 TO x
DO
FOR j:=1 TO y
DO
BEGIN
WRITE('elemen A[',i,',',j,'] :
');READLN(A[I,J]);
END;
WRITELN;
WRITELN ('Elemen 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('Hasil Perkalian Matrix A dan Matrix B adalah : ');
WRITELN;
FOR I:=1 TO X DO
BEGIN
FOR J:=1 TO Z
DO
WRITE(C[I,J],'
');
WRITELN;
END;
END.
1.2 LAYOUT GAMBAR
- Program Pascal Untuk Menampilkan Matrix Identitas Terbalik
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