Advertisement
MGM_user1

Untitled

Mar 10th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. //Date 3/9/2016 at city of Burgas  country of Bulgaria
  2. //Developed by Kristifor Milchev
  3.  
  4. #include <iostream>;
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int a, b;
  11.     cout << "Please input your range [n,n]" << endl;
  12.     cin >> a;
  13.     cin >> b;
  14.     cout << "Good your range for the bisection is equal to [" << a << "," << b << "]" << endl;
  15.     double R = a + b;
  16.     double FuncR = R / 2;
  17.     for (int i = 0; i < 100000; i++)
  18.     {
  19.         if (FuncR == 0)
  20.         {
  21.             cout << "You have found your root" << endl;
  22.             i = 100001;
  23.         }
  24.         else if(FuncR > 0)
  25.         {
  26.             a = FuncR;
  27.             R = a + b;
  28.             FuncR = R / 2;
  29.             if (FuncR ==0)
  30.             {
  31.                 cout << "You have found your root" << endl;
  32.                 i = 100001;
  33.             }
  34.         }
  35.         else
  36.         {
  37.             b = FuncR;
  38.             R = a + b;
  39.             FuncR = R / 2;
  40.             if (FuncR == 0)
  41.             {
  42.                 cout << "You have found your root" << endl;
  43.                 i = 100001;
  44.             }
  45.         }
  46.         if (i == 1000000)
  47.         {
  48.             cout << "No solution found" << endl;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement