解一元二次方程
#include<stdio.h>#include<math.h>
int main(void)
{
int a = 1;
int b = 2;
int c = 4;
double m;
m = b*b- 4 * a*c;
double x1;
double x2;
if (m > 0)
{
x1 = (-b + sqrt(m)) / (2 * a);
x2 = (-b - sqrt(m)) / (2 * a);
printf("改一元二次方程有两个解:x1 = %f,x2 =%f\n",x1,x2);
}
else if (m == 0)
{
x1 = (-b) / (2 * a);
x1 = x2;
printf("该一元二次方程有一个解:x1 = x2 =%f", x1);
}
else
{
printf("该方程无解\n");
}
getchar();
return 0;
}
跟我一直显示是无解,麻烦看一下有什么错误 谢谢