最开始还有点思路,后来越写越乱,
套的二分模版,不知道在写啥,
求大佬看看
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
const double eps=1e-5;
double check(double h){
return a*h*h*h+b*h*h+c*h+d;
}
int main(){
cin>>a>>b>>c>>d;
for(double i=-100;i<=100;i++){
if(check(i)==0){
printf("%.2lf ",i);
}
else if(check(i)*check(i+1)<0){
double l=i,r=i+1;
while(r-l>=eps){
double mid=(l+r)/2;
if(check(mid)==0){
printf("%.2lf ",mid);
}
else{
if(mid*r<=0)
l=mid;
else{
r=mid;
}
}
}
printf("%.2lf",r);
}
}
return 0;
}