如下:祥滑
#include <stdio.h>
#include <math.h>
int main()
{
float x, result;
printf("请输入x的值:");
scanf("%f",&x);
if(x <= 0)
{
result = 0;
}
else if(x <= 10)
{
result = sqrt(x);
}
else
{
result = 2 * x + 3;
}
printf("%f",result);
return 0;
}
扩展资料:
#include <stdio.h>
#include <math.h>
int main()
{
double x,y;
printf("input x:\n");
scanf("%lf",&x);
if (x< -1.0) y=x*x*x-1;
else if (x >=-1 && x <= 1) y=-3*x+1;
else if (x>1 && x <=10) y=3*exp(2*x-1)+5;
else y = 5*x + 3.0* log10(2*x*x-1) -13;
printf("%.2lf\n",y);
return 0;
}