70分怎么说
查看原帖
70分怎么说
1401041
zaobaiawa楼主2024/9/21 21:13
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
	double a,b,c,x1,x2;
	cin>>a>>b>>c;
	if(pow(b,2)-4*a*c<0||a==0)
		cout<<"No answer!";
	else
	{
		x1=(sqrt(pow(b,2)-4*a*c)-b)/(2*a);
		x2=((-1)*sqrt(pow(b,2)-4*a*c)-b)/(2*a);
		if(x1==x2)
			cout<<fixed<<setprecision(5)<<"x1=x2="<<x1;
		else if(x1>x2)
			cout<<fixed<<setprecision(5)<<"x2="<<x2<<";x1="<<x1;
		else
			cout<<fixed<<setprecision(5)<<"x1="<<x1<<";x2="<<x2;
	}
	return 0;
}
2024/9/21 21:13
加载中...