// PascalABC.NET 3.0, сборка 1160 от 05.02.2016 begin var a:=ArrRandom(ReadInteger('n='),-50,50); a.Println; var b:=a.Where(x->(x>0) and (x mod 3=0)).ToArray.Println end.
Const N = 20; var a, b: array[1..N] of integer; i, j: integer; begin writeln('Массив A:'); for i := 1 to N do begin a[i] := random(199) - 99; write(a[i] : 4); if (a[i] > 0) and (a[i] mod 3 = 0) then begin j := j + 1; b[j] := a[i]; end; end; writeln; writeln('Массив B:'); for i := 1 to j do write(b[i] : 4); end.
begin
var a:=ArrRandom(ReadInteger('n='),-50,50); a.Println;
var b:=a.Where(x->(x>0) and (x mod 3=0)).ToArray.Println
end.
Тестовое решение:
n= 15
15 39 -3 -40 6 -47 -19 -19 17 14 7 31 10 -37 -13
15 39 6
N = 20;
var
a, b: array[1..N] of integer;
i, j: integer;
begin
writeln('Массив A:');
for i := 1 to N do
begin
a[i] := random(199) - 99;
write(a[i] : 4);
if (a[i] > 0) and (a[i] mod 3 = 0) then
begin
j := j + 1;
b[j] := a[i];
end;
end;
writeln;
writeln('Массив B:');
for i := 1 to j do
write(b[i] : 4);
end.
Пример работы программы:
Массив A:
3 73 -1 -35 97 -14 25 34 -79 5 -39 39 45 96 -85 -59 -14 76 -53 -12
Массив B:
3 39 45 96