80求调
查看原帖
80求调
1636127
freeeeeee楼主2025/2/5 18:02
#include<bits/stdc++.h> 
using namespace std;
double a,b,c;
int main()
{
	cin>>a>>b>>c;
	double x1,x2,d=b*b-4*a*c;
	if(b*b-4*a*c<0)
	{
		cout<<"No answer";
		return 0;
	}
	x1=(-b+sqrt(d))/(2*a);
	x2=(-b-sqrt(d))/(2*a);
	if(x1>x2)
	{
		swap(x1,x2);
	}
	if(d==0)
	{
		cout<<fixed<<setprecision(5)<<"x1=x2="<<x1;
		return 0;
	}
	else
	{
		cout<<fixed<<setprecision(5)<<"x1="<<x1<<";x2="<<x2;
		return 0;
	}
}

2025/2/5 18:02
加载中...