Даны два целочисленных массива. найти сумму элементов первого массива, стоящих на четных местах , и заменить ею все элементы второго массива , стоящие на нечетных местах( в паскаль)
Program p1; const n = 10; var a: array[1..n] of integer; b: array[1..n] of integer; i, sum, j: integer; begin for i := 1 to n do begin a[i] := random(10);write(a[i], ' ') end;writeln; for i := 1 to n do begin b[i] := random(10);write(b[i], ' ') end;writeln; sum := 0; for i := 1 to n do if i mod 2 = 0 then sum := sum + a[i]; for i := 1 to n do if i mod 2 <> 0 then b[i] := sum; for i := 1 to n do write(b[i], ' ') end.
const n = 10;
var a: array[1..n] of integer; b: array[1..n] of integer; i, sum, j: integer;
begin
for i := 1 to n do begin a[i] := random(10);write(a[i], ' ') end;writeln;
for i := 1 to n do begin b[i] := random(10);write(b[i], ' ') end;writeln;
sum := 0;
for i := 1 to n do if i mod 2 = 0 then sum := sum + a[i];
for i := 1 to n do if i mod 2 <> 0 then b[i] := sum;
for i := 1 to n do write(b[i], ' ')
end.