#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#define EXP 0.000000001
int main()
{
double a, b, c,x, x1, x2, disc;
scanf("%lf%lf%lf", &a, &b, &c);
disc = b*b - 4*a*c;
if ((a > -EXP) && (a < EXP))
printf("不是一元二次方程");
else if ((disc>-EXP) && (disc < EXP))
{
x = -b / (2 * a);
printf("x=%lf\n", x);
}
else
{
if (disc>0.0)
{
x1 = (-b + sqrt(disc)) / (2 * a);
x2 = (-b - sqrt(disc)) / (2 * a);
printf("x1=%lf,x2=%lf\n", x1, x2);
}
else
printf("有两个共轭复根");
}
return 0;
}
10-27
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)