第一个样例输入是:
1 -2 -1 2
第一个样例输出是:
-1.00 1.00 2.00
我的代码如下
#include<iostream>
#include<cstdio>
using namespace std;
double a, b, c, d;
double saber(double tmp){
return a*tmp*tmp*tmp + b*tmp*tmp + c*tmp + d;
}
int main(){
scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
printf("\n");
for(double x=-100;x<=100;x+=0.001)
if(saber(x)*saber(x + 0.001) <= 0){
printf("%.2lf ", x);
x += 0.1;
}
return 0;
}
跑第一个样例输出应该是和标准输出一样啊,可为什么WA掉了?上面说第一行太短。