求告诉我这个算一元二次方程的程序哪儿错了?怎么算都不对啊 #include#includeint main(void){\x05int a = 1;\x05int b = 5;\x05int c = 6;double delta ;double x1;double x2;delta = b*b - 4*a*c; if(delta > 0){\x05x1 = (-b + sqrt (delt
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 20:42:54
求告诉我这个算一元二次方程的程序哪儿错了?怎么算都不对啊 #include#includeint main(void){\x05int a = 1;\x05int b = 5;\x05int c = 6;double delta ;double x1;double x2;delta = b*b - 4*a*c; if(delta > 0){\x05x1 = (-b + sqrt (delt
求告诉我这个算一元二次方程的程序哪儿错了?
怎么算都不对啊
#include
#include
int main(void)
{
\x05int a = 1;
\x05int b = 5;
\x05int c = 6;
double delta ;
double x1;
double x2;
delta = b*b - 4*a*c;
if(delta > 0)
{
\x05x1 = (-b + sqrt (delta)) / (2*a);
\x05x2 = (-b - sqrt (delta)) / (2*a);
\x05printf("x1=%f,x2=%f\n");
}
else if (delta == 0)
{
\x05x2=x1;
\x05x1= (-b)/(2*a);
\x05\x05printf("x2=x1=%f;\n");
}
else
{
printf("无解;\n");
return 0 ;
}
return 0 ;
}
求告诉我这个算一元二次方程的程序哪儿错了?怎么算都不对啊 #include#includeint main(void){\x05int a = 1;\x05int b = 5;\x05int c = 6;double delta ;double x1;double x2;delta = b*b - 4*a*c; if(delta > 0){\x05x1 = (-b + sqrt (delt
//printf()用法错了 把前两个printf()改成下面这样就对了 望采纳
if(delta > 0)
{
x1 = (-b + sqrt (delta)) / (2*a);
x2 = (-b - sqrt (delta)) / (2*a);
printf("x1=%f,x2=%f\n",x1,x2);//
}
else if (delta == 0)
{
x1= (-b)/(2*a);
x2=x1;
printf("x2 = x1 =%f;\n",x1);
}
else
{
printf("无解;\n");
return 0 ;
}