Ответ:
program Change;
var
n, i, j, t: Integer;
A: array of Integer;
begin
Write ('Введите четное число N: ');
ReadLn (n);
if n mod 2 = 0 then begin
SetLength (A, n);
Randomize;
for i := Low (A) to High (A) do begin
A [i] := Random (100);
Write (A [i] :3, ' ');
end;
i := 0;
while i < n do begin
t := A [i];
A [i] := A [i + 1];
A [i + 1] := t;
i := i + 2;
WriteLn;
end else
WriteLn ('Введено не четное число.');
ReadLn;
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
Ответ:
program Change;
var
n, i, j, t: Integer;
A: array of Integer;
begin
Write ('Введите четное число N: ');
ReadLn (n);
if n mod 2 = 0 then begin
SetLength (A, n);
Randomize;
for i := Low (A) to High (A) do begin
A [i] := Random (100);
Write (A [i] :3, ' ');
end;
i := 0;
while i < n do begin
t := A [i];
A [i] := A [i + 1];
A [i + 1] := t;
i := i + 2;
end;
WriteLn;
for i := Low (A) to High (A) do begin
Write (A [i] :3, ' ');
end;
end else
WriteLn ('Введено не четное число.');
ReadLn;
end.