文档详情

(精)最新c语言 编程题函数调用.doc

发布:2017-07-24约1.61千字共4页下载文档
文本预览下载声明
编程题 #include math.h #include stdio.h #include conio.h double fun(double x) { /**/ return (cos(3*x)+x*x-1)/fabs(exp(x)-2*1/tan(x)+1); /**/ } void main() { double x; printf(Pleae input x:); scanf(%lf,x); printf(\nfun(%6.3lf) = %6.3lf\n,x,fun(x)); getch(); } return((cos(3*x)+x*x-1) /fabs(exp(x)-2*tan(x)+1) ); } #include stdio.h #include math.h #include conio.h double fun(float x) { /**/ /**/ } void main() { float x; double y; printf(Please input a number: ); scanf(%f,x); printf(f(%.2f)=%.2f\n,x,fun(x)); getch(); } 参考答案: if(x1000) return x; else if(x=1000x2000) return (x-0.3*(x-1000)); else if(x=2000x3000) return (x-0.5*(x-1000)); else return(x-0.8*(x-1000)); #include stdio.h #include math.h #include conio.h double fun(float x) { /**/ /**/ } void main() { float x; double y; printf(Please input a number: ); scanf(%f,x); printf(f(%.2f)=%.2f\n,x,fun(x)); getch(); } 参考答案: if(x0) return x*x+1; else if(x=0x5) return (sqrt(3*x+1)); else return (log(x)); #include stdio.h #include math.h #include conio.h double fun(float x) { /**/ /**/ } void main() { float x; double y; printf(Please input a number: ); scanf(%f,x); printf(f(%.2f)=%.2f\n,x,fun(x)); getch(); } 参考答案: if(x2) return cos(x); else if(x==2) return (exp(x)+pow(x,3)); else return (fabs(1.23*x-9)); #include math.h #include stdio.h #include conio.h double fun(double x) { /**/ /**/ } void main() { printf(fun(2.53) = %6.3lf\n, fun(2.53)); getch(); } 参考答案: return((3*sin(x)+exp(x))/fabs(cos(x)-2*x));
显示全部
相似文档