90必关
查看原帖
90必关
1266484
michaelwanghaoyu楼主2024/10/26 22:00
#include<iostream>
#include<cmath>
#include<iomanip>
double a,b,c;
double x1;
double x2;
using namespace std;
int main()
{
	cin>>a>>b>>c;
	if((pow(b,2)-4*a*c)<0)
	{
		cout<<"No answer!";
		return 0;
	}
	x1=(-b+sqrt(pow(b,2)-4*a*c))/2/a;
	x2=(-b-sqrt(pow(b,2)-4*a*c))/2/a;
	if(x1!=x2)
	{
		cout<<fixed<<setprecision(5)<<"x1="<<min(x1,x2)<<';'<<"x2="<<max(x1,x2);
	}
	else
	{
		cout<<fixed<<setprecision(5)<<"x1=x2=",x1;
	}
	return 0;
}
2024/10/26 22:00
加载中...