В массиве A(n), состоящий из целых чисел, возвести в квадрат все нечетные отрицательные числа, а положительные четные заменить на единицу — Pascal(Паскаль)

Program ch;
uses crt;
var a:array [1..100] of integer;
     i,n:integer;
 
begin
Clrscr;
Write('Vvedite kolichestvo chisel, n=');
readln(n);
Write('Vvedite chisla');
for i:=1 to n do
read(a[i]);
 
for i := 1 to N do
  if (a[i] < 0) and odd(i) then
    a[i] := a[i] * a[i]
  else
    if (a[i] > 0) and not odd(i) then
      a[i] := 1;

Write(' Massiv=');
For i:=1 to n do
write(a[i]);
readln;
end.

Leave a Comment

− 1 = 3