
Создать массив из 20 случайных цэлых чисел из промежутка от минус 10 до 22 и вычесляет среднее
арифметическое чисел больших 5

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

var a:array[1..20] of integer;
i,sum,index:integer;
begin
for i:=1 to 20 do begin
a[i]:=random(32)-10;
if a[i]>5 then begin
sum:=sum+a[i];
index:=index+1;
end;
write(a[i],' ');
end;
writeln('Sredn=',sum/index);
end.



import random
A = [random.randint(-10, 22) for i in range(20)]
cnt = num = 0
for i in A:
if i >5:
cnt += i
num += 1
print "Среднее арифметическое - ", float(cnt)/float(num)



Creating an Array of 20 Random Integers and Calculating the Arithmetic Mean of Numbers Greater Than 5
To create an array of 20 random integers within the range from -10 to 22 and calculate the arithmetic mean of numbers greater than 5, you can use the following Python code:
```python import random
# Create an array of 20 random integers random_numbers = [random.randint(-10, 22) for _ in range(20)]
# Calculate the arithmetic mean of numbers greater than 5 numbers_greater_than_5 = [num for num in random_numbers if num > 5] arithmetic_mean = sum(numbers_greater_than_5) / len(numbers_greater_than_5)
print("Array of 20 random integers:", random_numbers) print("Numbers greater than 5:", numbers_greater_than_5) print("Arithmetic mean of numbers greater than 5:", arithmetic_mean) ```
This code uses the `random` module to generate random integers within the specified range and then calculates the arithmetic mean of the numbers greater than 5 within the array.
Let me know if you need further assistance with this!


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







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