提交时间:2024-03-09 16:28:34

运行 ID: 136963

#include <bits/stdc++.h> using namespace std; double x1,x2,a,b,c,d,xx; double x; double ask(double p) { return (a*p*p*p+b*p*p+c*p+d); } int main() { cin>>a>>b>>c>>d; for (x=-100;x<=100;x++) { x1=x;x2=x+1; if (ask(x1)==0) printf("%.2f ",x1); else if (ask(x1)*ask(x2)<0) { while (x2-x1>=0.001) { xx=(x1+x2)/2; if ((ask(x1)*ask(xx))<=0) x2=xx; else x1=xx; } printf("%.2f ",x1); } } cout<<endl; return 0; }