Код Pascal (Turbo/Free):
Var
x,u,dx:real;
Begin
Write('u = ');ReadLn(u);
dx:=0.2;
x:=-2.3;
Repeat
if x <= -1 then WriteLn('f(',x:0:1,') = ',Exp(3*Cos(x*x*x*x)))<br>else if x < 0.5 then WriteLn('f(',x:0:1,') = ',u/2)
else WriteLn('f(',x:0:1,') = ',x*x/(x*x*x+1));
x:=x+dx;
Until x > 1.2
End.
Код Pascal (ABC/ABC.NET):
Var
x,u,dx:real;
Begin
Write('u = ');ReadLn(u);
dx:=0.2;
x:=-2.3;
Repeat
if x <= -1 then WriteLn('f(',x:0:1,') = ',Power(Cos(Power(x,4)),3))<br>else if x < 0.5 then WriteLn('f(',x:0:1,') = ',u/2)
else WriteLn('f(',x:0:1,') = ',x*x/(Power(x,3)+1));
x:=x+dx;
Until x > 1.2
End.
Пример работы программы:
u = 3
f(-2.3) = -0.879705252481176
f(-2.1) = 0.563881010320276
f(-1.9) = 0.713305040376838
f(-1.7) = -0.109060103362282
f(-1.5) = 0.0403543461246888
f(-1.3) = -0.883417909038021
f(-1.1) = 0.00120774553073702
f(-0.9) = 1.5
f(-0.7) = 1.5
f(-0.5) = 1.5
f(-0.3) = 1.5
f(-0.1) = 1.5
f(0.1) = 1.5
f(0.3) = 1.5
f(0.5) = 0.222222222222222
f(0.7) = 0.364854802680566
f(0.9) = 0.468478889531521
f(1.1) = 0.519090519090519