Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <math.h>
- #include <conio.h>
- using namespace std;
- float y;
- float f(float x)
- { return sin(x)+sin(2*x)+x;
- }
- float DEI(float s, float d)
- {
- if(d-s<=0.0000001) return s;
- else
- { float m=(s+d)/2;
- if(f(m)==y) return m;
- else if(f(m)<y) return DEI(m,d);
- else return DEI(s,m);
- }
- }
- int main()
- {
- cin>>y;
- cout.precision(8);
- cout<<DEI(0,1);
- // system("pause");
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement