满意答案
smile暖若花开
2015.04.03
采纳率:55% 等级:9
已帮助:968人
#include
#include
#include
int main(void)
{
double a,b,c,d,e,f;
printf("请输入: a,b,c:");
scanf("%lf %lf %lf",&a,&b,&c);
d=b*b-4*a*c;
if( 0 == a )
{
if( 0 == b )
{
if( 0 == c )
{
printf("参数都为零,方程无意义\n");
}
else
{
printf("ab都为零,c不为零,方程不成立\n");
}
}
else
{
printf("x=%lf\n",-c/b);
}
}
else if( d>=0 )
{
printf("x1=%lf\n",(-b+sqrt(d))/(2*a));
printf("x2=%lf\n",(-b-sqrt(d))/(2*a));
}
else
{
printf("x1=%lf+%lf\n",-b/(2*a),sqrt(-d)/(2*a));
printf("x2=%lf-%lf\n",-b/(2*a),sqrt(-d)/(2*a));
}
getch();
return 0;
}
31分享举报