//2012-9-29 17:54:07
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float a, b, c, x1, x2, d;
cout<<"请输入a,b,c的值:"<<endl;
cin>>a>>b>>c;
d = b*b-4*a*c;
if (d>0)
{
x1 = (-b+sqrt(d))/(2*a);
x2 = (-b-sqrt(d))/(2*a);
cout<<"x1 = "<<x1<<endl<<"x2 = "<<x2<<endl;
}
else if (d == 0)
{
x1 = (-b+sqrt(d))/(2*a);
cout<<"x1 = x2 = "<<x1<<endl;
}
else
cout<<"该二元一次方程无解!"<<endl;
return 0;
}
21_求一元二次方程的根_完整版
最新推荐文章于 2023-03-31 00:26:37 发布