#include <stdio.h>
#include <math.h>
int main()
{
float a,b,c,x1,x2,d;
printf("Please enter the coefficients a,b,c:\n");
scanf("%f,%f,%f",&a,&b,&c);
if(a!=0)
{
d=sqrt(b*b-4*a*c);
if(b*b-4*a*c<0)
{
printf("error!\n");
}
else
{
x1=(-b+d)/(2*a);
x2=(-b-d)/(2*a);
printf("x1=%.4f, x2=%.4f\n",x1,x2);
}
}
return 0;
}
计算一元二次方程的根
于 2021-11-23 20:19:57 首次发布