
解决思路:二分法求方程根方法的方法如下:①取去区间[a,b]中点x=(a+b)/2;②若f(x)=0,即x为方程的根;③否则,若f(x)与f(a)同号,则变区间为[x,b],异号,则变区间[a,x];重复上述步骤,直到取到近似根。

关注我实现了一版,供你参考。如果有帮助,望采纳。
#include <math.h>
#include <stdio.h>
double f(double x) {
return 2 * pow(x, 3) - 4 * pow(x, 2) + 3 * x - 6;
}
int main() {
double lower = -10;
double upper = 10;
double x, y, _y;
while (1) {
x = (lower + upper) / 2;
y = f(x);
if (y == 0) {
break;
}
_y = f(lower);
if (y * _y > 0) { //同号
lower = x;
} else {
upper = x;
}
}
printf("%lf", x);
return 0;
}