👤
Deshtepu
a fost răspuns

Am nevoie de un program care poate calcula suma tuturor elementelor ce nu se află pe diagonala principală
Eu am încercat , rog să mă corectați


Program P79;
{ Suma componentelor variabilei m de tip Matrice }
const nmax=20;
type Matrice = array [1..nmax,1..nmax] of real;
var m : Matrice;
l, c : integer;
n:1..nmax;
s : real;

begin
WriteLn('introduceti n');
ReadLn(n);
writeln('dati componentele m[l,c]');
for l:=1 to n do
for c:=1 to n do

begin
write('m[', l, ',', c, ']=');
readln(m[l,c]);
end;
writeln('ati introdus');
for l:=1 to n do
begin
for c:=1 to n do write(m[l,c]);
writeln;
end;
if l<>c then

begin

s:=0;
for l:=1 to nmax do
for c:=1 to nmax do
s:=s+m[l,c];
end;

writeln('Suma=', s);
readln;
end.