题目太简单了,建议降红
查看原帖
题目太简单了,建议降红
1311164
MidnI_GHt楼主2024/9/28 21:24

太水了,一点技术含量都没有

我的AC代码:

#include <bits/stdc++.h>
using namespace std;
double a,b,c,d,x,x1,x2,xx;
double f(double x)
{
    return (x*x*x*a+x*x*b+x*c+d);
}
int main()
{
    cin>>a>>b>>c>>d;
    for(x=-100;x<=100;x++)
    {
        x1=x;x2=x+1;
        if(f(x1)==0) printf("%.2lf ",x1);
        else if(f(x1)*f(x2)<0)
        {
            while(x2-x1>=0.001)
            {
                xx=(x1+x2)/2;
                if((f(x1)*f(xx))<=0) x2=xx;
                else x1=xx;
            }
            printf("%.2lf ",x1);
        }
    }
    return 0;
}
2024/9/28 21:24
加载中...