标签:
这么简单并没有什么要说的
#include <iostream> using namespace std; double a3, a2, a1, a0; double fun(double x); int main() { double a, b, mid; cin >> a3 >> a2 >> a1 >> a0; cin >> a >> b; do{ if ((b-a)*1000<1.0){ printf("%.2lf", (a+b)/2); break; } mid = (a + b) / 2; if (fun(mid) ==0){ printf("%.2lf", mid); break; } else if (fun(mid)*fun(a)>0){ a = mid; } else{ b = mid; } } while (true); } double fun(double x) { return a3*x*x*x + a2*x*x + a1*x + a0; }
标签:
原文地址:http://www.cnblogs.com/zhouyiji/p/4555315.html