Const n=10; var a,b:array[1..n] of integer; i,y:integer; begin Randomize; writeln('Массив A:'); for i:=1 to n do begin a[i]:=random(51); write(a[i]:4); end; writeln; writeln('Массив B:'); for i:=1 to n do begin b[i]:=random(51); write(b[i]:4); end; writeln; y:=0; for i:=1 to n do if a[i]>b[i] then y:=y+a[i] else y:=y+b[i]; writeln('y = ',y); end.
Answers & Comments
Verified answer
Const n=10;var a,b:array[1..n] of integer;
i,y:integer;
begin
Randomize;
writeln('Массив A:');
for i:=1 to n do
begin
a[i]:=random(51);
write(a[i]:4);
end;
writeln;
writeln('Массив B:');
for i:=1 to n do
begin
b[i]:=random(51);
write(b[i]:4);
end;
writeln;
y:=0;
for i:=1 to n do
if a[i]>b[i] then y:=y+a[i] else y:=y+b[i];
writeln('y = ',y);
end.
Пример:
Массив A:
14 37 8 6 32 48 47 12 5 16
Массив B:
20 9 32 34 1 24 39 26 3 9
y = 297