新人求助,一元二次方程
# include <stdio.h># include <math.h>
int main (void)
{
float a;
float b;
float c;
double dalte;
double x1;
double x2;
printf ("请输入a,b,c的值:\n");
scanf("%f,%f,%f",&a,&b,&c);
dalte = b*b-4*a*c;
if (dalte > 0)
x1 = ((-b)+sqrt(dalte)) / (2*a);
x2 = ((-b)-sqrt(dalte)) / (2*a);
printf("该一元二次方程有两个解:x1 = %f\n, x2 = %f\n",x1, x2);
else if(dalte == 0)
x1 = -b/2*a;
x2 = x1;
printf ("该一元二次方程有唯一解:x1 = x2 = %f\n",x1);
else (dalte < 0)
printf ("该一元二次方程无解\n");
return 0;
}
想了半天,不知道错在哪里,求教,谢谢
[ 本帖最后由 yujian222000 于 2014-8-28 21:42 编辑 ]