Вопрос задан 19.09.2018 в 04:19. Предмет Информатика. Спрашивает Гуноев Мага.

Составьте программу которая заполняет массив A состоящая из 20 случайных целых чисел в диапазоне от

1 до 30 и выводит на экран элементы значения которых являются чётными и кратными трём
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Зверев Данил.
Program rand;
var i:integer;
A:array[1..20] of integer;
begin
randomize;
for i:=1 to 20 do
begin
A[i]:=random(30,1);
if (A[i] MOD 3=0) and (A[i] MOD 2=0) then
write(A[i],' ');
end;
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Fill an Array with Random Integers and Print Even and Multiples of Three

Here is a program written in JavaScript that fills an array with 20 random integers in the range from 1 to 30 and then prints the elements whose values are both even and multiples of three:

```javascript // Function to check if a number is even and a multiple of three function isEvenAndMultipleOfThree(number) { return number % 2 === 0 && number % 3 === 0; }

// Array to store the random integers var arrayA = [];

// Fill the array with 20 random integers for (var i = 0; i < 20; i++) { var randomInteger = Math.floor(Math.random() * 30) + 1; arrayA.push(randomInteger); }

// Print the elements that are even and multiples of three for (var i = 0; i < arrayA.length; i++) { if (isEvenAndMultipleOfThree(arrayA[i])) { console.log(arrayA[i]); } } ```

This program uses a `for` loop to fill the `arrayA` with 20 random integers in the range from 1 to 30. It then uses another `for` loop to iterate over the elements of `arrayA` and checks if each element is both even and a multiple of three using the `isEvenAndMultipleOfThree` function. If an element satisfies both conditions, it is printed to the console.

Please note that this program is written in JavaScript and can be executed in a JavaScript runtime environment, such as a web browser console or a Node.js environment.

Let me know if you have any further questions!

0 0

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

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

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