分段函数

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

      else

        y := 0.5 * x + 20;

  writeln(y:0:2);
end.
posted @ 2010-01-01 18:18  SmartIOI  阅读(149)  评论(0)    收藏  举报
本站采用CC授权如需转载、引用文章,请务必附上作者及来源处。 Creative Commons License