70分,蒟蒻求助
查看原帖
70分,蒟蒻求助
578842
zps1122楼主2022/4/17 09:34
#include<bits/stdc++.h>
using namespace std;
double a,b,c; 
double x1,x2;
int main(){
	cin>>a>>b>>c;
    if((b*b-4*a*c)<0){
        cout<<"No answer!";
        return 0;
}
	x1=(sqrt(b*b-4*a*c)-b)/(2*a);
	x2=(0-sqrt(b*b-4*a*c)-b)/(2*a);
    if(x1<x2){
	cout<<"x1=";
	cout<<fixed<<setprecision(5)<<x1;
	cout<<";x2=";
	cout<<fixed<<setprecision(5)<<x2;
}else if(x1>x2){
    cout<<"x2=";
	cout<<fixed<<setprecision(5)<<x2;
	cout<<";x1=";
	cout<<fixed<<setprecision(5)<<x1;
}else{
    cout<<"x1=x2=";
    cout<<fixed<<setprecision(5)<<x1;
}
	return 0;
}
```cpp
2022/4/17 09:34
加载中...