Google Translator
Penambahan Matrix with Pascal
program Penjumalahan_Matrix;
uses crt;
const
kolom=25;
baris=25;
type
matrix=array[1..baris,1..kolom] of integer;
var
matrix_A,matrix_B:matrix;
a,b:integer;
procedure InputMatrix(var x:matrix);
var
i,j:integer;
begin
for i:=1 to a do
begin
for j:=1 to b do
begin
Write('Masukan Elemen[',i,', ',j,'] : ');readln(x[i,j]);
end;
end;
end;
procedure CetakMatrix(var x:matrix);
var
i,j:integer;
begin
for i:=1 to a do
begin
for j:=1 to b do
begin
Write(x[i,j]:4);
end;
writeln;
end;
end;
procedure JumlahMatrix(var x,y:matrix);
var
z:matrix;
i,j:integer;
begin
for i:=1 to a do
begin
for j:=1 to b do
begin
z[i,j]:=x[i,j] + y[i,j];
Write(z[i,j]:4);
end;
writeln;
end;
end;
begin
write('Masukan Jumlah Baris : ');readln(a);
write('Masukan Jumlah Kolom : ');readln(b);
if (a>25) or (b>25) then
begin
writeln('Ada kesalahan ! max kolom dan baris adalah 25.');
exit;
end;
clrscr;
writeln('Input Martix A');
InputMatrix(matrix_A);
writeln;
writeln('Input Martix B');
InputMatrix(matrix_B);
clrscr;
writeln('Matrix A');
CetakMatrix(matrix_A);
writeln;
writeln('Matrix B');
CetakMatrix(matrix_B);
writeln;
writeln('Pemjumlahan Matrix A dan Matrix B');
JumlahMatrix(matrix_A,matrix_B);
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar
Masukan Pesan..
Tidak menerima spam..dan hal2 berbau porno jika melanggar comment akan di delete