5 solutions

  • 0
    @ 2024-7-28 21:20:47
    #include<iostream>
    #include<cmath>
    using namespace std;
    int main()
    {
        double a,b,c,x1,x2;
        scanf("%lf %lf %lf",&a,&b,&c);
        x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
        x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
        double res = b * b - 4 * a * c;
        if(res < 0){
            printf("No answer!");
        }else 
            if(res == 0){
                printf("x1=x2=%.5lf",x1);
            }else
                if(res > 0){
                    if(x1 > x2){
                        swap(x1,x2);
                    }
                    printf("x1=%.5lf;x2=%.5lf",x1,x2);
                }else printf("No answer!");
        return 0;
    }
    

    Information

    ID
    6735
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    9
    Tags
    (None)
    # Submissions
    718
    Accepted
    74
    Uploaded By