#include
#include
int main(void)
{
float a, b, c;
printf("input a, b, c:");
scanf("%f,%f,%f", &a, &b, &c);
float x1, x2;
if(!(a>-0.000001 && a < 0.000001))
{
x1 = (-b + sqrt(b*b - 4 * a * c)) / 2 * a;
x2 = (-b - sqrt(b*b - 4 * a * c)) / 2 * a;
}
else
{
x1 = x2 = (-b)/2 * a;
}
printf("x1 = %f, x2 = %f", x1, x2);
return 0;
}
for(x=0;x<100;i++)//根据x的取值范围来限定即可
if(a*x*x+b*x*c==0)
break;
printf("x=%d",x);
h=b*b-4a*c;
改成
h=b*b-4*a*c;
x1=b-sqrth);
改成
x1=b-sqrt(h);
哎学了忘,忘了学。