# include <stdio.h> # include <math.h> int main () {double a,b,c,disc,x1,x2,p,q; scanf("%1f%

2024-11-02 07:29:13
推荐回答(1个)
回答(1):

有些精确度问题吧?!
#include
#include
int main()
{
double a,b,c,p,q,disc,x1,x2;
scanf("%lf %lf %lf",&a,&b,&c); // double类型的字节长度为8,float为4.
disc=b*b-4*a*c;
if(disc<0)
printf("NO USEFULL ANSWER\n");
else
{
p=-b/(2*a);
q=sqrt(disc)/(2*a);
x1=p-q;
x2=p+q;
printf("x1=%lf\nx2=%lf",x1,x2);
};
return 0;
}