1 solutions

  • 0
    @ 2025-11-5 18:39:15

    C++ :

    #include <iostream>
    #include <cmath>
    using namespace std;
    int i,j,n;
    double f(double x)
    {
        return(pow(2,x)+pow(3,x)-pow(4,x));
    }
    main()
    {
          double x,r,l;
          r=2;l=1;
          x=(r+l)/2;
          while (f(x)!=0 && r-l>0.000000001)
          {
                if (f(r)*f(x)<0) l=x;
                else r=x;
                x=(r+l)/2;
          }
          printf("%0.10lf",x);
    }
    
    
    • 1

    Information

    ID
    18963
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By