const m=10; n=12; var a:array [1..m,1..n] of integer; i,j:integer; sob:integer; sst:array[1..n]of integer; sstr:array[1..m]of integer; begin randomize; for i:=1 to m do begin for j:=1 to n do begin a[i,j]:=random(10); write(a[i,j]:3); end; writeln; end; sob:=0; for i:=1 to m do begin for j:=1 to n do begin sob:=sob+a[i,j]; end; end; writeln('сумма всех элементов массива = ', sob); writeln; writeln; for i:=1 to m do begin sstr[i]:=0; for j:=1 to n do begin sstr[i]:=sstr[i]+a[i,j]; end; end; writeln('сумма элементов построчно'); for i:=1 to m do write(sstr[i]:3); writeln; writeln; for j:=1 to n do begin sst[j]:=0; for i:=1 to m do begin sst[j]:=sst[j]+a[i,j]; end; end; writeln('сумма элементов по столбцам'); for j:=1 to n do write(sst[j]:3); end.
Answers & Comments
const m=10; n=12;
var a:array [1..m,1..n] of integer;
i,j:integer;
sob:integer;
sst:array[1..n]of integer;
sstr:array[1..m]of integer;
begin
randomize;
for i:=1 to m do begin
for j:=1 to n do begin
a[i,j]:=random(10);
write(a[i,j]:3);
end;
writeln;
end;
sob:=0;
for i:=1 to m do begin
for j:=1 to n do begin
sob:=sob+a[i,j];
end;
end;
writeln('сумма всех элементов массива = ', sob);
writeln;
writeln;
for i:=1 to m do begin
sstr[i]:=0;
for j:=1 to n do begin
sstr[i]:=sstr[i]+a[i,j];
end;
end;
writeln('сумма элементов построчно');
for i:=1 to m do write(sstr[i]:3);
writeln;
writeln;
for j:=1 to n do begin
sst[j]:=0;
for i:=1 to m do begin
sst[j]:=sst[j]+a[i,j];
end;
end;
writeln('сумма элементов по столбцам');
for j:=1 to n do write(sst[j]:3);
end.