PASCAL ABC NETдан массив , состоящий из n элементов, элементы массива -произвольные целые числа , распечатать элементы в 2 строки . в 1 строке элементы с не четными индексами , а во 2 строке элементы с четными индексами
program PrintArray; var arr: array of Integer; n, i: Integer; begin Write('Enter the number of elements in the array: '); ReadLn(n);
// Dynamic array allocation SetLength(arr, n);
// Input elements of the array for i := 0 to n - 1 do begin Write('Enter element ', i+1, ': '); ReadLn(arr[i]); end;
// Print elements with odd indexes Write('Elements with odd indexes: '); for i := 0 to n - 1 do begin if (i mod 2 <> 0) then Write(arr[i], ' '); end; WriteLn;
// Print elements with even indexes Write('Elements with even indexes: '); for i := 0 to n - 1 do begin if (i mod 2 = 0) then Write(arr[i], ' '); end; WriteLn; end.
program PrintArray;
var
arr: array of Integer;
n, i: Integer;
begin
Write('Enter the number of elements in the array: ');
ReadLn(n);
// Dynamic array allocation
SetLength(arr, n);
// Input elements of the array
for i := 0 to n - 1 do
begin
Write('Enter element ', i+1, ': ');
ReadLn(arr[i]);
end;
// Print elements with odd indexes
Write('Elements with odd indexes: ');
for i := 0 to n - 1 do
begin
if (i mod 2 <> 0) then
Write(arr[i], ' ');
end;
WriteLn;
// Print elements with even indexes
Write('Elements with even indexes: ');
for i := 0 to n - 1 do
begin
if (i mod 2 = 0) then
Write(arr[i], ' ');
end;
WriteLn;
end.