十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
//if()實(shí)現(xiàn)

創(chuàng)新互聯(lián)建站專注于企業(yè)全網(wǎng)整合營(yíng)銷推廣、網(wǎng)站重做改版、龍海網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、成都h5網(wǎng)站建設(shè)、商城系統(tǒng)網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為龍海等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
#includeiostream.h
#includemath.h
void main()
{
double x,y;
cout"Enter X:";
cinx;
if(x0)//永遠(yuǎn)二分
cout"No defination\n";
else
{?? if(x10)
y=sin(x);
else
if(x20)
y=cos(x);
else
if(x30)
y=log(x+1);//ln(x+1)
else
if(x40)
y=-0.5*x;
else
cout"No defination\n";
}
if(x=0x40)
cout"y="yendl;
}
//switch()實(shí)現(xiàn)
#includeiostream.h
#includemath.h
void main()
{
double x,y;
cout"Enter X:";
cinx;
switch(int(x/10))//注意這里的技巧
{
case 0:y=sin(x);cout"y="yendl;break;
case 1:y=cos(x);cout"y="yendl;break;
case 2:y=log(x+1);cout"y="yendl;break;
case 3:y=-0.5*x;cout"y="yendl;break;
default:
cout"No defination"endl;
}
}
#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 SegmentFunction(int x){
if(x 1) return x;
else
if(x 10 || x == 10) return 3 * x -11;
else return 2 * x -1;
}
int main()
{
int in;
scanf("%d", in);
printf("%d", SegmentFunction(in));
return 0;
}
// 這種代碼我都懶的署名
#includeiomanip//小數(shù)位輸出控制函數(shù)頭文件;
#includeiostream
using namespace std;
int main()
{
float x,y;
cinx;
if(x=0x5)
y=-x+2.5;
if(x=5x10)
y=2-1.5*(x+3)*(x-3);
if(x=10x20)
y=x/2-1.5;
cout.setf(ios::showpoint);
cout.precision(3);//用來(lái)控制小數(shù)位輸出;
cout.setf(ios::fixed);
couty;
return 0;
}