Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Date 3/9/2016 at city of Burgas country of Bulgaria
- //Developed by Kristifor Milchev
- #include <iostream>;
- using namespace std;
- int main()
- {
- int a, b;
- cout << "Please input your range [n,n]" << endl;
- cin >> a;
- cin >> b;
- cout << "Good your range for the bisection is equal to [" << a << "," << b << "]" << endl;
- double R = a + b;
- double FuncR = R / 2;
- for (int i = 0; i < 100000; i++)
- {
- if (FuncR == 0)
- {
- cout << "You have found your root" << endl;
- i = 100001;
- }
- else if(FuncR > 0)
- {
- a = FuncR;
- R = a + b;
- FuncR = R / 2;
- if (FuncR ==0)
- {
- cout << "You have found your root" << endl;
- i = 100001;
- }
- }
- else
- {
- b = FuncR;
- R = a + b;
- FuncR = R / 2;
- if (FuncR == 0)
- {
- cout << "You have found your root" << endl;
- i = 100001;
- }
- }
- if (i == 1000000)
- {
- cout << "No solution found" << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement