如下:
肇东网站建设公司创新互联,肇东网站设计制作,有大型网站制作公司丰富经验。已为肇东成百上千家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的肇东做网站的公司定做!
#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;
}
扩展资料:
c语言计算分段函数值的简单代码:
#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 (x1 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;
}
#includestdio.h
#includemath.h
int main()
{double x,y;
scanf("%lf",x);
if(x=-2x!=5)y=x*x+1/(x+5);
else if(x-2x=0)y=sqrt(x+2)+x*x*x;
else if(x0x=10)y=log(x+5)/log(10)+exp(x-1);
else y=fabs(x-20);
printf("%lf\n",y);
return 0;
}
#include
int main()
{
int x,y;
scanf("%d",x);
if(0xx10) y=3*x+2;
else
{if(x=0) y=0;
else
{if (x0) y=x*x;
else printf("go die\n");
}
}
printf("%d",y);
return 0;
}该程序的分段函数如下:
f(x)=3x+2 (0x10)
f(x)=1 (x=0)
f(x) = x*x (x0)
#include stdio.h
#include math.h
void main()
{
float x;
double y;
printf("Please input the value of x:");
scanf("%f",x);
if(x=-10x=4)
{
y=fabs(x-2);
printf("y=%.2f\n",y);
}
else if(x=5x=7)
{
y=x+10;
printf("y=%.2f\n",y);
}
else if(x=8x=12)
{
y=pow(x,4);
printf("y=%.2f\n",y);
}
else
printf("No answer\n");
}
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款