#include iostream
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比葉城網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式葉城網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋葉城地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。
#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èi),再見!\n";
break;
}
if(x10)
cout"\n本函數(shù)的y值為:"y"。*^o^*\n";
return 0;
}
當x0且 x≠3 時 y=x*x +x-6
當 0=x0且x≠2及x≠3時 y=x*2-5x+6
當 x=其他 時 y=x*2-x-1
請問樓主,這是怎么分段的?當x0且 x≠3?x0還用且x不等于3嗎?0=x0?什么數(shù)不但大于等于0而且小于0?
#includestdio.h
#includemath.h
void main()
{
float x,y;
scanf("%f",x);
if(x0x!=3)
y=x*x+(x-6);
else if(x=0x!=2x!=3)
y=x*x-(5*x)+6;
else
y=x*x-x-1;
printf("%f",y);
}
#include?"stdio.h"
#include?"math.h"
int?main(int?argc,char?*argv[]){
double?x,y;
printf("Input?x(R:)...\nx=");
scanf("%lf",x);
if(x5)
y=-x+3.5;
else?if(x=5??x10)
y=20-3.5*pow(x+3,7);//這里看著像7,是幾就把7改成幾
else
y=-3.5+sin(x);
printf("y?=?%g\t(x==%g)\n",y,x);
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;
}該程序的分段函數(shù)如下:
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
int main()
{
float x,y;
printf("please input x:");
scanf("%f",x);
if(x0 x!=-3)
?y = pow(x,2)+x-6;
else if(x=0 x10 x!=2 x!=3)
?y = pow(x,2)-5*x+6;
else
?y = pow(x,2)-x-1;
printf("y=%f\n",y);
return 0;
}