分段函数
program jhbu;
var
x, y : real;
begin
write('please input a number: ');
read(x);
if x < 0 then
y := 0
else
if x < 10 then
y := x
else
if x < 20 then
y := 10
end.
var
x, y : real;
begin
write('please input a number: ');
read(x);
if x < 0 then
y := 0
else
if x < 10 then
y := x
else
if x < 20 then
y := 10
else
y := 0.5 * x + 20;
writeln(y:0:2);end.


浙公网安备 33010602011771号