90求助
查看原帖
90求助
1044970
LucAlva楼主2024/5/15 19:38
#include <bits/stdc++.h>
using namespace std;
int main(){
    double a,b,c;
    cin>>a>>b>>c;
    if(b*b-4*a*c<=0){
        cout<<"No answer!";
        return 0;
    }
    double x1=((0.0-b+sqrt(b*b-4*a*c)))/(2*a),x2=((0.0-b-sqrt(b*b-4*a*c)))/(2*a);
    if(x1==x2){
        cout<<"x1=x2="<<fixed<<setprecision(5)<<x1;
    }
    else{
        if(x1>x2) swap(x1,x2);
        cout<<"x1="<<fixed<<setprecision(5)<<x1<<";x2="<<fixed<<setprecision(5)<<x2;
    }
    return 0;
}
2024/5/15 19:38
加载中...