
Помогите пожалуйста!!! Дан целочисленный массив A размера N (<=15). Переписать в новый
целочисленный массив B все элементы с нечетными порядковыми номерами (1,3...) и вывести размер полученного массива B и его содержимое.Условный оператор не использовать

Ответы на вопрос

Как-то так)
const
n=15;
var
z:integer;
i:integer;
a:array[1..n] of integer;
b:array[1..(n div 2)+1]of integer;
begin
randomize;
for i:=1 to n do
begin
a[i]:=random(99)+1;
write(a[i],' ');
end;
writeln;
i:=-1;
z:=1;
while i<n do
begin
i:=i+2;
b[z]:=a[i];
z:=z+1;
end;
for i:=1 to (n div 2)+1 do write(b[i],' ');
end.



Reformatting an Integer Array
To reformat an integer array A of size N (where N <= 15) into a new integer array B containing all elements with odd indices, you can use the following Python code:
```python A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # Example input array A B = A[1::2] # Selecting elements with odd indices print(len(B)) # Output the size of the resulting array B print(B) # Output the content of the resulting array B ```
This code snippet creates a new array B by selecting elements from array A with odd indices and then outputs the size of array B and its content.
This approach utilizes Python's list slicing, where `A[1::2]` selects elements from index 1 to the end of the list with a step of 2, effectively picking elements with odd indices.
Feel free to replace the example input array A with your own array of integers to see the desired output.
If you have any further questions or need additional assistance, feel free to ask!


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili