#include<stdio.h>
#include<math.h> //运用sqrt
int main(){
double a, b, c, p, q, i_f;
scanf("%lf%lf%lf", &a, &b, &c);
printf("%f,%f,%f\n\n", a, b, c);
printf("the 方程式");
i_f = b*b - 4 * a*c;
p = -b / (2.0*a); q = sqrt(b*b - 4 * a*c) / (2.0*a);
/*a<=0.000001, 约等于0
1.a=0,不是方程式;
2.b^2-4ac=0,有俩相等实根;1,2,1
3.b^2-4ac>0,有俩不等实根;2 6 1
4.~~~~~~~<0,有俩共轭复根.1 2 2
*/
if (fabs(a)<= 1e-6)printf("it不是正确的,方程式");
if (fabs(i_f) <= 1e-6)printf("有俩相等实根,%5.2lf\n", p);
if (i_f>1e-6)printf("俩不等实根,%5.2lf,%5.2lf", p + q, p - q);
if (i_f < -(1e-6))printf("有俩共轭复根,%lf+%lfi;%lf-%lfi", p, q,p,q );
////////
system("pause");
return 0;
}
温馨提示:答案为网友推荐,仅供参考