有如下分段函数,编写程序,输入x,输出y值
y={ x (x<1)
根号下2x-1 (1≦x<20)
5x+10 (x≧20)
}
#include<stdio.h>
#include<math.h>
main()
{ float x,y,a,b;
scanf("%d",&x);
if(x<1)
printf("y=x=%f\n",x);
if((x>=1)&&(x<20))
a=sqrt(2*x-1);
printf("y=a=%f\n",a);
if(x>=20)
b=5*x+10;
printf("y=b=%f\n,b);}