#include iostream
创新互联长期为近1000家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为三江侗企业提供专业的成都做网站、网站建设,三江侗网站改版等技术服务。拥有十余年丰富建站经验和众多成功案例,为您定制开发。
#include cmath
int main()
{
using namespace std;
cout"请输入x的值(x10):";
double x,y;
cinx;
int n;
if(x=10x20)
n=1;
else if(x=20x30)
n=2;
else if(x=30x40)
n=3;
else if(x=40x50)
n=4;
else if(x=50)
n=5;
switch(n)
{
case 1:
y=log10(x);
break;
case 2:
y=log10(x)/log10(3);
break;
case 3:
y=cos(x);
break;
case 4:
y=pow(x,5);
break;
case 5:
y=1.0/tan(x);
break;
default:
cout"\n你输入的值不在取值范围内,再见!\n";
break;
}
if(x10)
cout"\n本函数的y值为:"y"。*^o^*\n";
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");
}
#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"); }
采纳哦