1 条题解

  • 1
    @ 2022-11-5 10:56:23
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        double a, b, c, delta, x1, x2;
        cin >> a >> b >> c;
        delta = b * b - 4 * a * c;
        if(delta>=0)
        {
            x1 = (-b + sqrt(delta)) / (2 * a);
            x2 = (-b - sqrt(delta)) / (2 * a);
            if (x1 > x2)
                swap(x1, x2);
            if (delta == 0)
                cout << fixed << setprecision(5) << "x1=x2=" << x1;
            else if(delta > 0) 
                cout << fixed << setprecision(5) << "x1=" << x1 << ";x2=" << x2;
        }
        else 
            cout << "No answer!";
        
        return 0;
    }
    
    • 1

    信息

    ID
    278
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    (无)
    递交数
    285
    已通过
    81
    上传者