[NOIP2001 提高组] 一元三次方程求解

#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,d,x1,x2,x3;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
for(double i=-100;i<=100;i+=0.001)//枚举每个答案
{
if(fabs(a*i*i*i+b*i*i+c*i+d)<0.0001)//避免double精度错误
printf("%.2lf ",i);
}
cout<<endl;
return 0;
}

posted @ 2022-08-14 10:26  zjtofficial  阅读(28)  评论(0编辑  收藏  举报