重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
#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"); }
10年積累的成都網站建設、成都做網站經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站設計后付款的網站建設流程,更有青河免費網站建設讓你可以放心的選擇與我們合作。
采納哦
輸入數用scanf()函數;
分段用switch()函數;
1、絕對值用math庫里面的abs()函數
2、e^x用math庫里面的pow(e,x)函數
3、同理指數的都有pow()函數,
4、cos函數也是math庫里面的double cos(double x)函數
補充:對于自變量x的不同的取值范圍,有著不同的對應法則,這樣的函數通常叫做分段函數。它是一個函數,而不是幾個函數;分段函數的定義域是各段函數定義域的并集,值域也是各段函數值域的并集。
int?fun(int?x){
int?result?=?0;
if(x0){
result?=?-x;
}else?if(x==0){
result?=?100;
}else?if(x0){
result?=?x*x+1;
}
return?result;
}
int?main(){
int?num?=?0;
scanf("%d",num);
printf("%d",fun(num));
return?0;
}
#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);
}
}
#include "stdio.h"
#include "math.h"
void main()
{
float x,y;
printf("x=");
scanf("%f",x);
if(x=0)
y=x*x-2;
else
y=sqrt(5-x);
printf("y=%0.2f\n",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;
}
運行樣例: