504课后习题
【题4.29】从键盘输入x,y的值,按下列公式求z的值。
((x*x+1)/(x*x+2))*y (x>=0,y>0)
z= (x-2)/(y*y+1) (x>0,y<=0)
x+y (x<0)
#include<stdio.h> #include<math.h> main() { float x,y,z; printf("输入x,y:\n"); scanf("%f,%f",&x,&y); if(x>=0&&y>0) z=((x*x+1)/(x*x+2))*y; else if(x>0&&y<=0) z=(x-2)/(y*y+1); else z=x+y; printf("z=%f\n",z); return 0; }
望老师斧正!