Calcula la multiplicacion entre dos matrices
pascal:
{-Victor De la Rocha}
{-Algoritmia@groups.msn.com}
{-www.myalgorithm.com}
program matrices;
uses
crt;
type
matriz = array[1..3,1..3] of integer;
var
mat1,mat2,mat3 : matriz;
i,j,k,acum : integer;
begin
randomize;
clrscr;
Writeln('Asigne valores a las Matrices 1 y 2');
for i:= 1 to 3 do
for j:= 1 to 3 do
begin
write('mat1[',i,',',j,']=');
{readln(mat1[i,j]);}
mat1[i,j]:=random(10);
end;
for i:= 1 to 3 do
for j:= 1 to 3 do
begin
write('mat2[',i,',',j,']=');
{readln(mat2[i,j]);}
mat2[i,j]:=random(10);
end;
for i := 1 to 3 do
for j := 1 to 3 do
begin
acum := 0;
for k := 1 to 3 do
acum := acum + mat1[i,k] * mat2[k,j];
mat3[i,j]:= acum;
end;
clrscr;
{Imprime en pantalla matriz1}
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
gotoxy((j*4)+2,(i*1)+6);
write(mat1[i,j]);
end;
end;
gotoxy(7,12);write('matriz 1');
{Imprime en pantalla matriz2}
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
gotoxy((j*4)+15,(i*1)+2);
write(mat2[i,j]);
end;
end;
gotoxy(33,4);write('matriz 2');
{Imprime en pantalla matriz3}
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
gotoxy((j*4)+15,(i*1)+6);
write(mat3[i,j],'');
end;
end;
gotoxy(32,11);write('Matriz 3');
readln;
end.
{-Algoritmia@groups.msn.com}
{-www.myalgorithm.com}
program matrices;
uses
crt;
type
matriz = array[1..3,1..3] of integer;
var
mat1,mat2,mat3 : matriz;
i,j,k,acum : integer;
begin
randomize;
clrscr;
Writeln('Asigne valores a las Matrices 1 y 2');
for i:= 1 to 3 do
for j:= 1 to 3 do
begin
write('mat1[',i,',',j,']=');
{readln(mat1[i,j]);}
mat1[i,j]:=random(10);
end;
for i:= 1 to 3 do
for j:= 1 to 3 do
begin
write('mat2[',i,',',j,']=');
{readln(mat2[i,j]);}
mat2[i,j]:=random(10);
end;
for i := 1 to 3 do
for j := 1 to 3 do
begin
acum := 0;
for k := 1 to 3 do
acum := acum + mat1[i,k] * mat2[k,j];
mat3[i,j]:= acum;
end;
clrscr;
{Imprime en pantalla matriz1}
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
gotoxy((j*4)+2,(i*1)+6);
write(mat1[i,j]);
end;
end;
gotoxy(7,12);write('matriz 1');
{Imprime en pantalla matriz2}
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
gotoxy((j*4)+15,(i*1)+2);
write(mat2[i,j]);
end;
end;
gotoxy(33,4);write('matriz 2');
{Imprime en pantalla matriz3}
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
gotoxy((j*4)+15,(i*1)+6);
write(mat3[i,j],'');
end;
end;
gotoxy(32,11);write('Matriz 3');
readln;
end.
ERROR: Simulacion no establecida para este programa. Intente ejecutando el codigo en su computadora