Var
sum, count, t : integer;
begin
sum := 0; count := 0;
while not eoln do
begin
read (t);
if t > 0 then
begin
sum := sum + t;
count := count + 1;
end;
writeln (sum, ' ', count);
end.
если количество элементов указано
var
sum, count, t, n, i : integer;
begin
sum := 0; count := 0;
read (n);
for i := 1 to n do
begin
read (t);
if t > 0 then
begin
sum := sum + t;
count := count + 1;
end;
writeln (sum, ' ', count);
end.
1 в,
2 б,
3- 8 штук: ---, --+, -+-, -++, +--, +-+, ++-,+++.
4- 4,
5-г,
6 - б
7- г
8- атхуатжа:)
var a,b,c,y,x,z:real;
begin
readln(a,b,c);
writeln('a = ',a);
writeln('b = ',b);
writeln('c = ',c);
writeln('y = ',(a-2)/(b*b-c):0:3);
writeln('x = ',(b*b+4*a*c)/(2*a):0:3);
writeln('z = ',(a/b)+(c/a)-((a*b+c*c)/(b*c)):0:3);
end.
def f():
counter = 0
for num in range(100,1000):
if num % 3 == 0 and num % 10 == 2:
counter += 1
return counter
Уже после ответа придумал еще одну функцию, делает то же самое.
def f():
return len([x for x in range(100, 1000) if x % 3 == 0 and x % 10 == 2])