用C++求解一元二次方程的程序有什么错误?//解一元二次方程的C++程序#include #include #include double sqrt1(double,double); double sqrt2(double,double); double printer(double,double);void main() { float a,b,c; double x1,x2; cou
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 05:52:35
用C++求解一元二次方程的程序有什么错误?//解一元二次方程的C++程序#include #include #include double sqrt1(double,double); double sqrt2(double,double); double printer(double,double);void main() { float a,b,c; double x1,x2; cou
用C++求解一元二次方程的程序有什么错误?
//解一元二次方程的C++程序
#include
#include
#include
double sqrt1(double,double);
double sqrt2(double,double);
double printer(double,double);
void main()
{
float a,b,c;
double x1,x2;
coutb>>c;
if(b*b-4*a*c !=0)
{
if(b*b-4*a*c)
{
sqrt1(x1,x2);
}
else
{
printer(x1,x2);
}
}
else
{
sqrt2(x1,x2);
}
double sqrt1(double x1,double x2) //b*b-4ac>0
{
float a,b,c;
if(a!=0)
{
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout
用C++求解一元二次方程的程序有什么错误?//解一元二次方程的C++程序#include #include #include double sqrt1(double,double); double sqrt2(double,double); double printer(double,double);void main() { float a,b,c; double x1,x2; cou
//解一元二次方程的C++程序
#include
#include
#include
void sqrt1(double,double);
void sqrt2(double,double);
void printer(double,double);
void main()
{
float a,b,c;
double x1,x2;
coutb>>c;
if(b*b-4*a*c !=0)
{
if(b*b-4*a*c)
{
sqrt1(x1,x2);
}
else
{
printer(x1,x2);
}
}
else
{
sqrt2(x1,x2);
}
}
void sqrt1(double x1,double x2) //b*b-4ac>0
{
float a,b,c;
if(a!=0)
{
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout