90分求助 #2wrong answer too short on line 1
查看原帖
90分求助 #2wrong answer too short on line 1
677955
Streetlights楼主2022/2/14 10:38
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    double a,b,c,d;
    cin>>a>>b>>c;
    d = pow(b,2)-4*a*c;
    if (d>0)
    {
        if (a>0)
        cout<<"x1="<<fixed<<setprecision(5)<<(-b-sqrt(d))/2.0/a<<";x2="<<(-b+sqrt(d))/2.0/a<<endl;
        else
        cout<<"x1="<<fixed<<setprecision(5)<<(-b+sqrt(d))/2.0/a<<";x2="<<(-b-sqrt(d))/2.0/a<<endl;
    }
    else if (d==0)
        cout<<"x1=x2="<<(-b)/2.0/a<<endl;
    else
        cout<<"No answer!"<<endl;
    return 0;
}
2022/2/14 10:38
加载中...