C语言代码,新手,帮忙看看哪里有错误

#include
#include
int main()
{
double a,b,c,disc,x1,x2,realpart,imagpart;
scanf("%lf,%lf,%lf",&a,&b,&c);
printf("The equation");
if(fabs(a)<=1e-6)
printf("is not a quadratic.\n ");
else
{
disc=b*b-4*a*c;
if(fabs(disc)<=1e-6)
printf(" has two equal roots:%8.4f\n",-b/(2*a));
else if(fabs(disc)>1e-6)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf(" has two toots:%8.4fand%8.4f\n",x1,x2);
}
else
{
realpart=-b/(2*a);
imagpart=(b*b-4*a*c)/(2*a);
printf(" has complex roots:\n");
printf("%8.4f+%8.4fi",realpart,imagpart);
printf("%8.4f-%8.4fi",realpart,imagpart);
}
}
return 0;
}
图片说明

查看全部
a547720714
Immanito
2015/09/17 08:47
  • c
  • 点赞
  • 收藏
  • 回答
    私信

3个回复