Pascal/Turbo Pascal - producto de matrices

 
Vista:

producto de matrices

Publicado por estudiante (1 intervención) el 16/11/2006 19:23:24
querria saber como acer un prorama en el que se multipliquen dos matrices cuadradas de orden N.gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:producto de matrices

Publicado por Andres (7 intervenciones) el 17/11/2006 04:03:13
HOLA LETICIA COMO ANDAS?

AHI VA UN EJEMPLO PARA QUE TE QUEDE CLARO:

PROGRAM ProductoMatrices (input,output);
CONST
M = 4; {de orden 4}
N = 4; {de orden 4}
TYPE
RangoM = 1..M;
RangoN = 1..N;
MatrizNxN = ARRAY[RangoM,RangoN] OF integer;
MatrizMxM = ARRAY[RangoM,RangoN] OF integer;
VAR
Matriz1:MatrizNxN;
Matriz2:MatrizNxN;
Matriz3:MatrizNxN;
i,j,k,acum:integer;

BEGIN
writeln('Escriba los valores de la matriz 1:');
FOR i:= 1 TO M DO
BEGIN
FOR j:= 1 TO N DO
BEGIN
read(Matriz1[i,j]);
END;
readln;
END;

writeln('Escriba los valores de la matriz 2:');
FOR i:= 1 TO M DO
BEGIN
FOR j:= 1 TO N DO
BEGIN
read(Matriz2[i,j]);
END;
readln;
END;

FOR i:= 1 TO MDO
FOR j:= 1 TO N DO
BEGIN
acum:= 0;
FOR k:= 1 TO M DO
acum:=acum + Matriz1[i,k] * Matriz2[k,j];
Matriz3[i,j]:=acum;
END;

writeln('El producto de la matriz 1 con la matriz 2 es:');
writeln('Matriz 3:');
FOR i:= 1 TO MDO
BEGIN
FOR j:= 1 TO N DO
BEGIN
write(Matriz3[i,j]);
write(' ');
END;
writeln;
END;

readln;

Saludos.-

END.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar