Ответ:
Ответ
Проверено экспертом
Ответ дан
Aillianna
1)
var
a1, a2, b1, b2, c, i, n: integer;
s: array [1..100] of integer;
begin
read(n);
for i := 1 to n do
s[i] := random(100);
if s[i] < 50 then
a1 := a1 + s[i];
a2 := a2 + 1;
end;
if s[i] >= 50 then
b1 := b1 + s[i];
b2 := b2 + 1;writeln(a1 / a2:0:3, ' ', b1 / b2:0:3);
import random
N = [random.randint(0, 100) for i in range(10)]
print ("Array is:", N)
sum_less_50 = 0
Count_less_50 = 0
sum_more_50 = 0
Count_more_50 = 0
for elem in N:
if elem >= 50:
Count_more_50 += 1
sum_more_50 += elem
else:
Count_less_50 += 1
sum_less_50 += elem
print("Awerage of nums, that < 50: ", end = "")
if Count_less_50 > 0:
print(sum_less_50 / Count_less_50)
print(0)
print("Awerage of nums, that >= 50: ", end= "")
if Count_more_50 > 0:
print(sum_more_50 / Count_more_50)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
Ответ
Проверено экспертом
Ответ дан
Aillianna
Aillianna
1)
var
a1, a2, b1, b2, c, i, n: integer;
s: array [1..100] of integer;
begin
read(n);
for i := 1 to n do
begin
s[i] := random(100);
if s[i] < 50 then
begin
a1 := a1 + s[i];
a2 := a2 + 1;
end;
if s[i] >= 50 then
begin
b1 := b1 + s[i];
b2 := b2 + 1;writeln(a1 / a2:0:3, ' ', b1 / b2:0:3);
import random
N = [random.randint(0, 100) for i in range(10)]
print ("Array is:", N)
sum_less_50 = 0
Count_less_50 = 0
sum_more_50 = 0
Count_more_50 = 0
for elem in N:
if elem >= 50:
Count_more_50 += 1
sum_more_50 += elem
else:
Count_less_50 += 1
sum_less_50 += elem
print("Awerage of nums, that < 50: ", end = "")
if Count_less_50 > 0:
print(sum_less_50 / Count_less_50)
else:
print(0)
print("Awerage of nums, that >= 50: ", end= "")
if Count_more_50 > 0:
print(sum_more_50 / Count_more_50)
else:
print(0)