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

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

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.



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!


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