Matrices Programación 1
program Suma_de_2_matriz;
uses
crt, dos;
const
m_rango = 5;
type
rango = 1..m_rango;
mientero = integer;
tmatriz = array[rango,rango] of mientero;
var
matriz: tmatriz;fil,col: rango;
procedure cargar(var mat : tmatriz; m,n:rango);
var
i,j: rango;
begin
clrscr;
for i:= 1 to m do
for j:= 1 to n do
begin
write(' Ingrese el valor [',i,',',j, '] = ');readln(mat[i,j]);
end;
readkey;
end;
Function promedio(mat : tmatriz; m,n: rango): real;
var
cant,i ,j : rango;
suma, prom: real;
begin
clrscr;
suma:=0;
for i:=1 to m do
begin
for j:= 1 to ndo
suma:= suma + matriz[i,j];
end;
cant:= fil*col;
prom:= suma/cant;
write(' El promedio es: ',prom:0:2);
promedio:= prom;
readkey;
end;
begin
clrscr;
write(' Ingrese la cantidad defilas: ');
readln(fil);
write(' Ingrese la cantidad de columnas: ');
readln(col);
cargar(matriz,fil,col);
promedio(matriz,fil,col);
end.
Forma Directa.
program arreglo;
uses crt;
varmatriz:array[1..3,1..5] of integer;
ren,col:integer;
suma:integer;
begin
clrscr;
writeln('suma de matrices');
writeln;
for ren:=1 to 3 do
begin
for col:=1 to 5 dobegin
write('elemento[',ren,',',col,']:');
readln(matriz[ren,col]);
end;
end;
clrscr;
writeln('matriz');
writeln;
suma:=0;
for ren:=1 to 3 do
begin
for col:= 1to 5 do
begin clrscr;
suma:=suma+matriz[ren,col];
write(matriz[ren,col]:3);
write('la suma es:',suma);writeln
end;
end;
writeln;
write('presione cualquier tecla paracontinuar');
repeat until keypressed;
end.
Arreglo de Dos Dimenciones.
1. Definir Variables:
a) Matriz: Arreglo [1..3, 1..5 ] Entero.
b) Ren ,col: Entero.
c) Suma: Entero.2. Leer la suma de Matices.
a) solicitar el arreglo de Matriz.
b) Leer el arreglo de Matriz.
3. Siclo del Arreglo:
For Ren : 1 asta 3
For Col : 1 asta...
Regístrate para leer el documento completo.