增大器:哪儿错了

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/12 12:36:46
#include <math.h>
main()
{
double x,y;
printf("please enter a number ;\n");
scanf("%f",&x);
if(x>3)y=double log10(double x);
else if(x<-3)y=(x-3);
else y=sqrt(9-x*x);
printf("y=%f\n",y);
}

y=double log10(double x); ??什么意思
如果你要使用强制类型转换的话,应该如下写:
y=(double)log10((double)x);
或是直接写:y=log10(x);

#include <math.h>
main()
{
double x,y;
printf("please enter a number ;\n");
scanf("%f",&x);
if(x>3)y=x;
else if(x<-3)y=(x-3);
else y=sqrt(9-x*x);
printf("y=%f\n",y);
}