萌新提问,为什么一定要用两点差判断,暴力搜索直接代值为啥求不出答案
查看原帖
萌新提问,为什么一定要用两点差判断,暴力搜索直接代值为啥求不出答案
878821
b1acat楼主2023/1/6 03:08

代码如下,运行不出来结果。想知道为啥这样不行啊

#include<bits/stdc++.h>
using namespace std;
double a,b,c,d;

double fun(double x){
	return a*x*x*x+b*x*x+c*x+d;
}

int main(){
	scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
	for(double i=-100.00;i<=100.00;i+=0.01){
		if(fun(i)==0) printf("%.2lf",i);
	}
}
2023/1/6 03:08
加载中...