дан массив 5*6. Найти среднее арифметическое в каждой строке. Результаты положить в одномерный массив. паскаль
Answers & Comments
Befri
Program z; var s,i,j,n,m:integer; a:array [1..100,1..100] of integer; b:array [1..100] of real; begin n:=5; m:=6; for i:=1 to n do for j:=1 to m do begin writeln ('vvedi elementy'); readln (a[i,j]); end; for i:=1 to n do begin for j:=1 to m do begin write (a[i,j]:5); end; writeln; end; for i:=1 to n do begin s:=0; for j:=1 to m do begin s:=s+a[i,j]; end; b[i]:=s/m; end; for i:=1 to n do writeln (b[i]:5:1); readln; end.
Answers & Comments
var
s,i,j,n,m:integer;
a:array [1..100,1..100] of integer;
b:array [1..100] of real;
begin
n:=5; m:=6;
for i:=1 to n do
for j:=1 to m do
begin
writeln ('vvedi elementy');
readln (a[i,j]);
end;
for i:=1 to n do
begin
for j:=1 to m do
begin
write (a[i,j]:5);
end;
writeln;
end;
for i:=1 to n do
begin
s:=0;
for j:=1 to m do
begin
s:=s+a[i,j];
end;
b[i]:=s/m;
end;
for i:=1 to n do
writeln (b[i]:5:1);
readln;
end.