// PascalABC.NET 3.0, сборка 1139 от 10.01.2016 begin var n:=ReadInteger('Количество элементов в массиве: '); var a:=ArrRandom(n,-50,50); a.Println(','); Writeln('Четные элементы: '); var i:=1; while i<n do begin Write(a[i],' '); Inc(i,2) end; Writeln; Writeln('Нечетные элементы: '); i:=0; while i<n-1 do begin Write(a[i],' '); Inc(i,2) end; Writeln end.
Тестовое решение: Количество элементов в массиве: 10 15,-18,-29,-25,46,21,-8,-17,-9,15 Четные элементы: -18 -25 21 -17 15 Нечетные элементы: 15 -29 46 -8 -9
Const n=15; var i,np,nn,amax:integer; a:array[1..n] of integer; begin Randomize; Write('Исходный массив: '); np:=0; nn:=0; for i:=1 to n do begin a[i]:=Random(51)-15; Write(a[i],' '); if a[i]>0 then Inc(np) else if a[i]<0 then Inc(nn); end; Writeln; if np/nn>2 then begin amax:=a[i]; for i:=2 to n do if a[i]>amax then amax:=a[i]; Write('Выходной массив: '); for i:=1 to n do begin if a[i]<0 then a[i]:=1 else if a[i]>0 then a[i]:=a[i]*amax; Write(a[i],' ') end; Writeln end else Writeln('В массив изменения не вносятся') end.