程序没错,可运行的结果不对
#include <stdio.h>#include <math.h>
void main()
{
float a,b,c,p,q,disc,x1,x2;
scanf("a=%lf b=%lf c=%lf",&a,&b,&c);
p=-b/(2*a);
disc=b*b-4*a*c;
q=sqrt(disc)/(2*a);
x1=p+q;
x2=p-q;
printf("x1=%2.3f\nx2=%2.3f\n",x1,x2);
}
可以运行,但是值不对,求解释,谢谢 scanf(); 语句中 %lf 改为 %f scanf("a=%lf b=%lf c=%lf",&a,&b,&c);应该改为scanf("%f %f %f", &a, &b, &c); scanf(); 语句中 %lf 改为 %f
页:
[1]