Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double fx(double x)
- {
- return pow(x,2)-cos(x);
- }
- int main()
- {
- float x = 0;
- float y = 0;
- cout <<"x=";
- cin >> x;
- cout << "y=";
- cin >> y;
- double R=(x+y)/2;
- double f, esp=pow(-25.0,0);
- while (fabs(x-y)>=esp)
- {
- f=(x+y)/2;
- if(f<0) x=R;
- if(f>0) y=R;
- R=(x+y)/2;
- cout<<"f("<<x<<")= "<<R<<endl;
- }
- cout<<"x= "<<x<<endl;
- cout<<"y= "<<y<<endl;
- cout<<"realen koren= "<<R;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement