这是个求2元一次方程解的情况的程序,我给加了个主函数,有点不对,高手帮帮
#include <stdio.h>#include <math.h>
int main()
{
float a,b,c,m;
scanf("%f%F%F",&a,&b,&c);
m=solv_quadr_equa(a,b,c);
printf("%f%f%F",a,b,c);
return 0;
}
void solv_quadr_equa (float a,float b,float c)
{
if(a==0)
if(b==0)
printf("no answer due to input error\n");
else
printf("the single root is %f\n",-c/b);
else
{double disc,twoa,term1,term2;
disc=b*b-4*a*c;
twoa=2*a;
term1=-b/twoa;
term2=sqrt (fabs (disc)/twoa;
if(disc<0.0)
printf("complex root:\n real part=%f,imag part=%f\n",term1,term2);
else
printf("real root:\n root1=%f,root2=%f\n",term1+term2,term1-term2);
}
}