PascalABC.Net
begin
var (c, n) := ReadInteger2('Введите C and N');
var a := ArrRandom(n, -44, 35).Println;
a.Where(z -> z > c).Average.Println;
end.
const n = 20;
var a: array [1..n] of integer;
i, C, sum, count: integer;
readln(C);
for i := 1 to n do
a[i] := Random(35 + 44 + 1) - 44;
write(a[i]:4);
end;
writeln();
sum := 0;
count := 0;
if a[i] > C then
sum := sum + a[i];
count := count + 1;
if count = 0 then
count := 1;
writeln('Среднее арифм.: ', (sum / count):4:2);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
PascalABC.Net
begin
var (c, n) := ReadInteger2('Введите C and N');
var a := ArrRandom(n, -44, 35).Println;
a.Where(z -> z > c).Average.Println;
end.
const n = 20;
var a: array [1..n] of integer;
i, C, sum, count: integer;
begin
readln(C);
for i := 1 to n do
begin
a[i] := Random(35 + 44 + 1) - 44;
write(a[i]:4);
end;
writeln();
sum := 0;
count := 0;
for i := 1 to n do
if a[i] > C then
begin
sum := sum + a[i];
count := count + 1;
end;
if count = 0 then
count := 1;
writeln('Среднее арифм.: ', (sum / count):4:2);
end.