#includestdio.h

在陸川等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都做網(wǎng)站、成都網(wǎng)站建設(shè) 網(wǎng)站設(shè)計制作定制設(shè)計,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計,網(wǎng)絡(luò)營銷推廣,成都外貿(mào)網(wǎng)站制作,陸川網(wǎng)站建設(shè)費用合理。
#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 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語言計算分段函數(shù)值的簡單代碼:
#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
viod
main()
{
int
x,y;
scanf("%d",x);
if(x的第一個取值范圍)
y=相應(yīng)關(guān)于x的函數(shù);
else
if(x的第二個取值范圍)
y=相應(yīng)關(guān)于x的函數(shù);
else
if(x的第三個取值范圍)
y=相應(yīng)關(guān)于x的函數(shù);
printf("%d",y);
}
圖自己畫,簡單。
#include stdio.h
#include math.h
int main(void)
{
int repeat, ri;
double x, y;
scanf("%d", repeat);
for(ri = 1; ri = repeat; ri++){
scanf("%lf",x);
y=x=0?sqrt(x):pow(x+1,2)+2*x+1/x;
printf("f(%.2f) = %.2f\n", x, y);
}
}
幫你改了下代碼,VC6測試通過,自己看看吧。
#includestdio.h
int main()
{
float x,y;//根據(jù)給定的測試用例,x,y應(yīng)該為float型
scanf("%f",x);//x為float型,所以改為%f
if(x20)
{
y=x+100;
}
else if(x=20x=100)
{
y=x;
}
else
y=x-100;
printf("x=%f,y=%f\n",x,y);
return 0;//缺少分號
}
標(biāo)題名稱:C語言分段函數(shù)輸入任意x,c語言如何輸入分段函數(shù)
文章源于:http://chinadenli.net/article8/dsesiip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、用戶體驗、靜態(tài)網(wǎng)站、網(wǎng)站收錄、企業(yè)網(wǎng)站制作、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)