为什么我把函数放在另一个文件就不好用?
#include <stdio.h>#include <math.h>
main()
{
void da ( float a, float b, float disc );
void deng ( float a, float b, float c );
void xiao ( float a, float b, float c, float disc );
float a, b, c, disc;
scanf ("%f%f%f",&a,&b,&c);
disc = b * b - 4 * a * c;
if ( disc > 0 )
da(a,b,disc);
else
if ( disc == 0 )
deng (a, b, c);
else
xiao (a, b, c, disc);
}
void deng ( float a, float b, float c )//如果b的平方减4ac等于0
{
printf ("two equal roots: %f\n",- b / ( 2 * a ) );
}
void xiao ( float a, float b, float c, float disc ) ////如果b的平方减4ac小于0
{
float p, q;
p = - b / ( 2 * a );
q = sqrt(-disc) / (2 * a);
printf ("two complex roots:%f+ %fi\n",p,q);
printf ("%f- %fi\n",p,q);
}
void da ( float a, float b, float disc) //如果b的平方减4ac大于0
{
float x1, x2;
x1 = (-b + sqrt(disc))/(2*a);
x2 = (-b - sqrt(disc))/(2*a);
printf ("%f\n%f\n",x1,x2);
}
求二次方程的根,如果我把三个函数分别放在其他3个文件里,求的值就不正确,我把他们合到一个文件中就好用了,请问这是为什么?