Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- double funcction (int a, int b, int c, int d, double x)
- {
- double y;
- y = a*x*x*x + b*x*x + c*x + d;
- return y;
- }
- int main()
- {
- int a, b, c, d;
- double eps = 0.000001;
- cin >> a >> b >> c >> d;
- double first = -10000;
- double last = 10000;
- while (last - first > eps)
- {
- double middle = (last + first)/2;
- if (funcction(a, b, c, d, middle)*funcction(a, b, c, d, last) > 0)
- last = middle;
- else first = middle;
- }
- cout.precision(6);
- cout << fixed << first;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement