70分求助
查看原帖
70分求助
918770
_HJS_楼主2023/7/31 11:52
/*****************************************
备注:
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
signed main()
{	

	double a,b,c;
	cin>>a>>b>>c;
	if(a==0)
	{
		cout<<"No answer!";
		return 0; 
	}
	if((b*b)-(4*a*c)<0)
	{
		cout<<"No answer!";
		return 0;
	}
	double x1=((-b)+sqrt((b*b)-(4*a*c)))/(2*a);
	double x2=((-b)-sqrt((b*b)-(4*a*c)))/(2*a);
	if(x1==x2)
	{
		cout<<"x1=x2=";
		cout<<fixed<<setprecision(5)<<x1<<endl;
	}
	else if(x1!=x2)
	{
		cout<<"x1=";
		cout<<fixed<<setprecision(5)<<x1<<";";
		cout<<"x2=";
		cout<<fixed<<setprecision(5)<<x2; 
	}
	else
	{
		cout<<"No answer!";
	}
	return 0;
}

2023/7/31 11:52
加载中...