Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. double fx(double x)
  5. {
  6. return pow(x,2)-cos(x);
  7. }
  8.  
  9. int main()
  10. {  
  11. float x = 0;
  12. float y = 0;
  13.   cout <<"x=";
  14.   cin >> x;
  15.   cout << "y=";
  16.   cin >> y;
  17.  
  18. double R=(x+y)/2;
  19. double f, esp=pow(-25.0,0);
  20. while (fabs(x-y)>=esp)
  21. {
  22. f=(x+y)/2;
  23. if(f<0) x=R;
  24. if(f>0) y=R;
  25. R=(x+y)/2;
  26. cout<<"f("<<x<<")= "<<R<<endl;
  27. }
  28.  
  29.  cout<<"x= "<<x<<endl;
  30.  cout<<"y= "<<y<<endl;
  31.  cout<<"realen koren= "<<R;
  32.  
  33.  return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement