Program Penjumlhkan_Matriks_AAABBB;
uses crt;
type matriks= array[1..4,1..3] of integer;
var
A,b,c:matriks;
m,n: integer; //m byak baris,dan n byk kolom
// procedure isi_matriks
procedure isi_matriks(var m,n:integer;var A,B:matriks) ;
var
i,j : integer;
begin
write('bnyk baris: ');readln(m);
write('bnyk kolom: ');readln(n);
clrscr;
gotoxy(27,1);write('penjumlahan 2 buah matriks');
//mengisi matriks A
window(5,3,35,11);textbackground(2);clrscr;
textcolor(15);
gotoxy(12,1);write('matriks A');
gotoxy(12,2);write('=========');
for i := 1 to m do
begin
for j:= 1 to n do
begin
gotoxy(j*5,i+2);
readln(A[i,j]);
end;
end;
//mengisi matriks B
window(45,3,75,11);textbackground(3);clrscr;
textcolor(15);
gotoxy(12,1);write('matriks B');
gotoxy(12,2);write('=========');
for i := 1 to m do
begin
for j:= 1 to n do
begin
gotoxy(j*5,i+2);
readln(A[i,j]);
end;
end;
end;
// penjumlahan matriks
procedure penjumlahan(m,n:integer;A,B:matriks;var C:matriks) ;
var
i,j : integer;
begin
for i := 1 to m do
begin
for j:= 1 to n do
begin
C[i,j]:=A[i,j] + B[i,j];
end;
end;
end;
//tampil dataa,.
procedure tampil_hasil(m,n:integer;var C:matriks) ;
var
i,j : integer;
begin
//menampilkan matriks hsil penj.
window(25,13,55,21);textbackground(4);clrscr;
textcolor(15);
gotoxy(10,1);write('matriks hasil');
gotoxy(10,2);write('=============');
for i := 1 to m do
begin
for j:= 1 to n do
begin
gotoxy(j*5,i+2);delay(800);write(C[i,j]);
end;
end;
end;
//prog utama
begin
gotoxy(24,1);writeln('penjumlahan 2 buah matriks');
isi_matriks(m,n,A,B) ;
penjumlahan(m,n,A,B,C);
tampil_hasil(m,n,C) ;
readln;
end.
Tidak ada komentar:
Posting Komentar