有一函数,其函数关系如下,试编程求对应于每个自变量的函数值

img


#include <stdio.h>
#include <math.h>
int main()
{
    double x,y;
    scanf("%lf",&x);
    if(x < 0)
        y = x*x;
    else if( x >=0 && x < 10)
        y = -0.5 * x + 10;
    else
        y = x - sqrt(x);
    printf("y = %g\n",y);
    return 0;
}