C
Sa se determine suma elementelor pe fiecare linie si coloana a unei matrici in C sau PascalSe citeste m,n dimensiunea unei matrici A=(a[i,j])mxn de valori reale. Sa se determine suma elementelor pe fiecare linie si coloana. program matrice3; var m,n,i,j:word; a:array[1..50,1..50] of real; sl,sc:array[1..50] of real; BEGIN write('Introduceti nr de linii m=');readln(m); write('Introduceti nr de coloane n=');readln(n); for i:=1 to m do begin for j:=1 to n do begin write('a[',i,',',j,']='); read(a[i,j]); end; writeln; end; for i:=1 to m do sl[i]:=0; for j:=1 to n do sc[j]:=0; for i:=1 to m do begin for j:=1 to n do sl[i]:=sl[i]+a[i,j]; writeln('suma elementelor de pe linia ',i,'=',sl[i]:6:2); end; for j:=1 to n do begin for i:=1 to m do sc[j]:=sc[j]+a[i,j]; writeln('suma elementelor de pe coloana ',j,'=',sc[j]:6:2); end; readln; END. // varianta C #include <stdio.h> unsigned m,n,i,j; float a[50][50]; float sl[50],sc[50]; void main(void) putchar('n'); for (i=0;i<m;i++) sl[i]=0; for (j=0;j<n;j++) sc[j]=0; for (i=0;i<m;i++) for (j=0;j<n;j++)
|