4 solutions

  • 0
    @ 2023-10-6 11:48:09
    #include<math.h>
    int main()
    {
        double a,b,c,d,x1,x2,e;
        scanf("%lf %lf %lf",&a,&b,&c);
        d=b*b-4*a*c;
        if(d<0){
            printf("No answer!");
        }else{
            if(d==0){
                x1=x2=(-b)/(2*a);
                printf("x1=x2=%.5f",x1);
            }else{
                e=sqrt(d);
                x1=(-b+e)/(2*a);
                x2=(-b-e)/(2*a);
               if(x1<x2){
                printf("x1=%.5f;x2=%.5f",x1,x2);
                }else{
                    printf("x1=%.5f;x2=%.5f",x2,x1);
                    }
            }
        }return 0;
    }
    

    Information

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