求救救救!!!
大佬们,这个求根的代码是哪里有问题嘛,为什么每次求出来的结果都是x1=-1.#J,x2=-1.#J呢?万分感谢!代码如下:
#include <stdio.h>
#include <math.h>
void main()
{
double a, b, c, disc, x1, x2, p, q;
scanf("a=%lf,b=%lf,c=%lf", &a, &b, &c);
disc = b*b-4*a*c;
p = -b/(2*a);
q = sqrt(disc)/(2*a);
x1 = p+q;
x2 = p-q;
printf("\nx1=%5.2f\nx2=%5.2f\n", x1, x2);
} 用的是dev-c++
页:
[1]