首先条件里面if(a==0),不是a=0,包括下面的dise,这是一个错误。
第二个错误是当条件语句下面有多条执行的语句需要用{}把这些语句包含进去。
#include
int main()
{
double a, b, c, x1, x2, dise;
printf("input a b c:");
scanf("%lf%lf%lf", &a, &b, &c);
if (a == 0)
printf("该方程不是一元二次方程");
else
{
dise = b * b - 4 * a * c;
if (dise == 0)
printf("有两个相等的实根: %lf", -b / (2 * a));
else if (dise > 0)
{
x1 = (-b + sqrt(dise)) / (2 * a);
x2 = (-b - sqrt(dise)) / (2 * a);
printf("有两个不相等的实根: %lf, %lf", x1, x2);
}
else
printf("没有实根");
}
return 0;
}
emmm……你倒数第二个if后面的几个语句(到下一个else之前)应该用{}括起来。