#include <stdio.h>#include <math.h>double fun(float x){?/**/if(x>=10)? ?return ?log(3*x);? if(x>=1&&x<10)? ?return sqrt(2*x-1);? if(x<1)? ?return fabs(x); ?/**/}void main(){? float x;? double y;? clrscr();? printf("Please input a number:\n");? scanf("%f",&x);? y = fun(x);? printf("f(%.2f)=%.2f\n",x,y);? getch();}?第一張圖是第一種方法運(yùn)行出來(lái)的錯(cuò)誤第二種方法if(x>=10) k=log(3*x); else if(x>=1&&x<10) k=sqrt(2*x-1); else? if(x<1) k=fabs(x); return k;?第二種方法運(yùn)行出來(lái)的錯(cuò)誤
- 1 回答
- 0 關(guān)注
- 1013 瀏覽
添加回答
舉報(bào)
0/150
提交
取消