代码:

#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;
double a,b,c,d;

double f(double p){
	return a*pow(p,3)+b*pow(p,2)+c*p+d;
}

int main()
{
	bool flag=true;
	double x,y;
	cin>>a>>b>>c>>d;
	cin>>x>>y;
	while((y-x)>0)
	{
		if(f((x+y)/2)==0){
			cout<<fixed<<setprecision(2)<<(x+y)/2;
			flag=false;
			break;
		}
		else if(f((x+y)/2)*f(x)>0){
			x=(x+y)/2;
		}
		else {
			y=(x+y)/2;
		}
	}
	if(flag){
		cout<<fixed<<setprecision(2)<<(a+b)/2<<endl;
	}
	return 0;
}

扣了两分,但是看不出来阈值的设置,改成0.01还是不行,找了网上的答案感觉写的差不多一样,zzz,那就差两分吧…头皮发麻,zzz,多捞哦.