Вопрос задан 11.08.2018 в 04:54. Предмет Информатика. Спрашивает Незнаева Катерина.

Помогите пожалуйста!!! Дан целочисленный массив A размера N (<=15). Переписать в новый

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

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает DELETED.
Easy
Как-то так)
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.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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!

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос