Program jumlah_dua_matriks;
uses wincrt;
type
matrik= array[1..50,1..50] of integer;
var
matrika, matrikb : matrik;
a,b : integer;
procedure baca_matrik(var c :matrik);
var
i,j : integer;
begin
for i:=1 to a do;
begin
for j:=1 to b do;
begin
write(' elemen elemen [',i,',',j,']:');
readln(c[i,j]);
end;
end;
end;
procedure tulis_matrik ( var c : matrik);
var
i,j : integer;
begin
for i:=1 to a do
begin
for j:=1 to b do
begin
write(c[i,j]:6);
end;
writeln;
end;
end;
function jumlah( var c,d : matrik) : integer;
var z : matrik;
i, j : integer;
begin
for i :=1 to a do
begin for j:=1 to b do
begin
z[i,j] :=c[i,j] + d[i,j];
write(z[i,j]:4);
end;
writeln;
end;
end;
begin
write(' masukkan jumlah baris :'); readln(a);
write(' masukkan jumlah kolom :'); readln(b);
clrscr;
writeln(' baca matrik a');
baca_matrik(matrika);
writeln(' baca matrik b');
baca_matrik(matrikb);
writeln;
writeln(' penjumlahan matrik a dan b ');
jumlah(matrika,matrikb);
readln;
end.
0 Komentar:
Posting Komentar