Const xn=-2; xk=2; h=0.2;
var x,y:real; i,n,k:integer;
begin
x:=xn-h;
n:=round((xk-xn)/h)+1;
k:=0;
writeln(' x y');
for i:=1 to n do
begin
x:=x+h;
y:=x*cos(2*x);
if y>0 then k:=k+1;
writeln(x:4:1,y:7:3);
end;
writeln('k=',k);
end.
Результат:
x y
-2.0 1.307
-1.8 1.614
-1.6 1.597
-1.4 1.319
-1.2 0.885
-1.0 0.416
-0.8 0.023
-0.6 -0.217
-0.4 -0.279
-0.2 -0.184
0.0 0.000
0.2 0.184
0.4 0.279
0.6 0.217
0.8 -0.023
1.0 -0.416
1.2 -0.885
1.4 -1.319
1.6 -1.597
1.8 -1.614
2.0 -1.307
k=10