#include<stdio.h>
#include<math.h>
int main()
{ float a,b,c;
float x1,x2,m;
printf("Please enter the coefficients a,b,c:\n");
scanf("%f,%f,%f",&a,&b,&c);
m=b*b-4*a*c;
x1=(-b)/(2*a)+sqrt(b*b-4*a*c)/(2*a);
x2=(-b)/(2*a)-sqrt(b*b-4*a*c)/(2*a);
if(m<0)
{
printf("error!\n");
}
else
{
printf("x1=%.4f, x2=%.4f\n",x1,x2);
}
return 0;
}
求根公式: