70分,救救我!救救我!
查看原帖
70分,救救我!救救我!
1182116
wzfly_www楼主2023/12/30 18:28
#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){
		cout<<"No answer!";
		return 0;
	}
	x1=(-b+sqrt(b*b-4*a*c))/(2*a);
	x2=(-b-sqrt(b*b-4*a*c))/(2*a);
	if(x1==x2){
		cout<<fixed<<setprecision(5)<<"x1=x2="<<x1;
	}else if(x1<x2){
		cout<<fixed<<setprecision(5)<<"x1="<<x1<<";x2="<<x2;
	}else{
		cout<<fixed<<setprecision(5)<<"x2="<<x2<<";x1="<<x1;
	}
	return 0;
}
2023/12/30 18:28
加载中...