#include<stdio.h>
int main() {
double x,y,z;
scanf("%lf %lf",&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 if(x<0){
z=x+y;
}
printf("%lf",z);
return 0;
}
有帮助请采纳
#include <stdio.h>
#include <stdlib.h>
int main() {
int x,y;
double z;
scanf("%d,%d",&x,&y);
if(x>=0 && y>0) {
z=((float)(x*x+1)/(x*x+2))*y;
} else if(x>0 &&y<=0) {
z=(float)(x-2)/(y*y+1);
} else if(x<0) {
z=x+y;
}
printf("z=%f",z);
return 0;
}