#include using namespace std; #include double F(double x) { double res = pow(x, 9) - pow(x, 7) + 2 * pow(x, 2) -1; return res; } double low, high; cout<<"low="; cin>>low; cout<<"high="; cin>>high; for(int i = 0; i < 1000 ; ++i){ double mid = (float)(low + high)/2; double val = F(mid); cout << mid << ":" << val << endl; if(val < 0.00001 && val > -0.00001){ cout << "Root is " << mid << endl; return; } else if (val < 0 ) low = mid; else high = mid; } } int main(int argc, char **argv){ print_roots(); system("pause"); return 0; }