用double定义出现的一些问题。/。求解
#include "stdio.h"double fnfun(double x);
double fnfun(double x)
{ double y;
if(x>1)
y=x*x+1;
else if(-1<=x&&x<=1)
y=x*x;
else if(x<-1)
y=x*x-1;
return y;
}
void main()
{ double x,result;
printf("please input x:");
scanf("%f",&x);
result=fnfun(x);
printf("y=%f",result);
getch();
}
为什么X输入任何值。。求得的Y都是0.00000