#include <stdio.h>
#include <math.h>
fun1(float a,float b,float c)
{
float m,n,d;
d=b*b-a*c*4;
m=-b/(2*a);
n=sqrt(-d)/(2*a);
printf("方程有虚数1:%.2f+%.2fi\n ",m,n);
printf("方程有虚数2:%.2f-%.2fi\n",m,n);
}
fun2(float a,float b,float c)
{
printf("方程有唯一解:%.2f\n",-b/(2*a));
}
fun3(float a,float b,float c)
{
float x1,x2,d;
d=b*b-a*c*4;
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("方程有两个解%.2f %.2f\n",x1,x2);
}
int main()
{
float a,b,c;
scanf("%f%f%f",&a,&b,&c);
if(b*b<a*c*4)
fun1(a,b,c);
else if(b*b==a*c*4)
fun2(a,b,c);
else
fun3(a,b,c);
return 0;
}
辛苦的写出来了!!!调试通过
望采纳!