#include
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供羅平網(wǎng)站建設(shè)、羅平做網(wǎng)站、羅平網(wǎng)站設(shè)計(jì)、羅平網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、羅平企業(yè)網(wǎng)站模板建站服務(wù),十多年羅平做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
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?
int?main()?
{double?x,y;
scanf("%lf",x);
if(x0)y=x*x-1;
else?if(x1)y=x*x;
else?y=x*x+1;
printf("%g",y);
return?0;?
}
main函數(shù)里讀取x的值的時(shí)候,要用%lf,因?yàn)閤是double型,如果是float型,則是用%f。
你試試。
int?sign(int?x)
{
int?y;
scanf("%d",x);
if(x0)
y=1;
else?if(x==0)//判斷語(yǔ)句是==不是=號(hào)
y=0;
else
y=-1;
return?y;
}