1. Традиционное решение
const
n=10;
var
x,y:array[1..n] of integer;
sx,sy,i:integer;
begin
Randomize;
Write('X: ');
sx:=0;
for i:=1 to n do begin
x[i]:=Random(101)-50;
Write(x[i],' ');
sx:=sx+x[i]
end;
Writeln;
Write('Y: ');
sy:=0;
for i:=1 to n do begin
y[i]:=Random(101)-50;
Write(y[i],' ');
sy:=sy+y[i]
end;
Writeln;
Writeln('Сумма х= ',sx,', сумма y= ',sy);
if sx>sy then for i:=1 to n do y[i]:=0
else for i:=1 to n do x[i]:=0;
Write('X: ');
for i:=1 to n do Write(x[i],' ');
Writeln;
Write('Y: ');
for i:=1 to n do Write(y[i],' ');
Writeln
end.
Пример
X: 4 29 -50 -18 37 -43 -18 9 41 28
Y: -8 41 -18 -6 -10 -10 47 -8 -29 25
Сумма х= 19, сумма y= 24
X: 0 0 0 0 0 0 0 0 0 0
Y: -8 41 -18 -6 -10 -10 47 -8 -29 25
2. Аналогичное решение средствами PascalABC.Net 3.2
const
n=10;
begin
var x:=ArrRandom(n,-50,50); Write('X: '); x.Println;
var y:=ArrRandom(n,-50,50); Write('Y: '); y.Println;
var sx:=x.Sum; var sy:=y.Sum;
Writeln('Сумма х= ',sx,', сумма y= ',sy);
if sx>sy then y:=ArrFill(n,0) else x:=ArrFill(n,0);
Write('X: '); x.Println;
Write('Y: '); y.Println
end.
Выбирать вам...)))