Вопрос задан 17.02.2019 в 15:49. Предмет Информатика. Спрашивает Гурджян Сабрина.

Составьте программу нахождения в массиве а( 10) индексов элементов значения которых не кратны 4

0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Панченко Маша.
// составьте программу нахождения в массиве а( 10) индексов элементов значения которых не кратны 4

var i,x: word;
    a  : array [1..10] of integer;
Begin
  writeln ('Введите 10 целых чисел');
  for i:=1 to 10 do
    Begin
      write (i,' число ');
      readln (a[i]);
    end;
  writeln;
  for i:=1 to 10 do
    Begin
      x:=a[i] mod 4;
      if x<>0 then writeln (i,' элемент таблицы не кратен 4');
    end;
End.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Find Indices of Elements Not Divisible by 4 in an Array

To create a program to find the indices of elements in an array that are not divisible by 4, you can use the following JavaScript code:

```javascript function findIndicesNotDivisibleByFour(arr) { let indices = []; for (let i = 0; i < arr.length; i++) { if (arr[i] % 4 !== 0) { indices.push(i); } } return indices; }

// Example usage let array = [10, 8, 5, 16, 20, 7, 9]; let result = findIndicesNotDivisibleByFour(array); console.log(result); // Output: [2, 5, 6] ```

This program defines a function `findIndicesNotDivisibleByFour` that takes an array as input and returns an array of indices where the elements are not divisible by 4. It iterates through the input array and checks each element for divisibility by 4, pushing the index to the `indices` array if the element does not meet the condition.

This code snippet is based on the logic of iterating through the array and checking the divisibility of each element by 4, as per the principles of JavaScript programming

0 0

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

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

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