#include "stdio.h"
#include "math.h"
void main(void)
{
float genone(float a,float b,float c);
float gentwo(float a,float b,float c);
float a,b,c,x1,x2;
float d;
printf("input 3 numbers:");
scanf("%f,%f,%f",&a,&b,&c);
d=-4*a*c+b*b;
if(d>1e-6)
{
x1=genone(a,b,d);
x2=gentwo(a,b,d);
printf("x1=%f,x2=%f",x1,x2);
}
else if(d==0)
{x1=x2=genone(a,b,c);
printf("x1=x2=%f",x1);}
else
printf("There is no answer.");
}
float genone(float a,float b,float c)
{
float n=-b+sqrt(c);
n=n/(2*a);
return n;
}
float gentwo(float a,float b,float c)
{
float m=(-b-sqrt(c))/(2*a);
return m;
}
我又一次纠结了。。虽然可以运行,但是结果不对。δ的的结果是正确的,但是函数的结果不对。