
Срочно! 1)Дан массив из 15 элементов в диапазоне от -36 до 48. Найти количество элементов,
которые кратны 3 и не кратны 4. 2)Дан массив из 10 элементов в диапазоне от -126 до 77. Найти сумму наибольшего и наименьшего элементов. в виде программы для Паскаля!

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

Программа:
Pascal:
№1)
var
arr: array[1..15] of integer;
count, i: integer;
begin
for i := 1 to 15 do begin
arr[i] := random(-36, 48);
if (arr[i] mod 3 = 0) and (arr[i] mod 4 <> 0) then inc(count);
end;
writeln(arr, #10, count);
end.
№2)
var
arr: array[1..10] of integer;
min, max, i: integer;
begin
min := MAXINT; max := -MAXINT;
for i := 1 to 10 do begin
arr[i] := random(-126, 77);
if arr[i] < min then min := arr[i];
if arr[i] > max then max := arr[i];
end;
writeln(arr, #10, max + min);
end.



Task 1: Finding the number of elements that are divisible by 3 but not by 4 in a given array
To find the number of elements in a given array that are divisible by 3 but not by 4, you can follow these steps:
1. Initialize a variable `count` to 0. This variable will keep track of the number of elements that meet the given condition. 2. Iterate through each element in the array. 3. For each element, check if it is divisible by 3 using the modulo operator (%). If the remainder is 0, it means the element is divisible by 3. 4. If the element is divisible by 3, check if it is not divisible by 4 using the same modulo operator (%). If the remainder is not 0, it means the element is not divisible by 4. 5. If both conditions are met, increment the `count` variable by 1. 6. After iterating through all the elements, the value of `count` will represent the number of elements that are divisible by 3 but not by 4.
Here's an example program in Pascal that implements this logic:
```pascal program CountElements;
const SIZE = 15;
var arr: array[1..SIZE] of Integer; i, count: Integer;
begin count := 0;
{ Initialize the array with random values } for i := 1 to SIZE do arr[i] := Random(85) - 36; { Generates random numbers between -36 and 48 }
{ Count the elements that meet the condition } for i := 1 to SIZE do begin if (arr[i] mod 3 = 0) and (arr[i] mod 4 <> 0) then count := count + 1; end;
writeln('The number of elements divisible by 3 but not by 4 is: ', count); end. ```
Please note that the above program generates random numbers between -36 and 48 for the array elements using the `Random` function. You can modify this part of the code to use your own array or input method.


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







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