哪错了,求各位大神救一下
查看原帖
哪错了,求各位大神救一下
1646956
moyofu楼主2025/1/21 09:27
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,c,x1,x2;
	cin>>a>>b>>c;
	if (b*b-4*a*c==0)
	{
		x1=x2=-b/2*a;
		cout<<"x1=x2="<<x1;
	}
	else if (b*b-4*a*c>0)
	{
		x1=(-b+sqrt(b*b-4*a*c))/(2*a);
		x2=(-b-sqrt(b*b-4*a*c))/(2*a);
		cout<<"x1="<<fixed<<setprecision(5)<<min(x1,x2)<<";"<<"x2="<<fixed<<setprecision(5)<<max(x1,x2);
	}
	else
	{
		cout<<"No answer!";
	}
    return 0;
}
2025/1/21 09:27
加载中...