求x^5-3x-1在0到1间的值
#include<stdio.h>
#include< math.h >
#pragma warning(disable:4996)
double fx(double ax)
{ double y;
y = pow(ax, 5) - 3 * ax - 1; //此处写函数
printf("平均数函数值 %lf\n", y);
return y;
}
int main()
{ puts("请输入两个自变量值");
double a, b;
double max, min, ax, y;
scanf("%lf %lf", &a, &b);
max = (a > b) ? a : b;
min = (b < a) ? b : a;
printf("你输入的max=%lf min=%lf\n\n\n", max, min);
int i ;
for (i=1;i<=100;i++)
{printf("第%d次的运算\n", i);
ax = (min + max) / 2;
printf("平均函数值 %lf\n", ax);
y=fx(ax);
min = (y < 0) ? ax :min;
max = (y > 0) ? ax : max;
printf("现在的 max=%lf min=%lf\n", max, min);
printf("交点值结果为 %lf\n\n\n\n",(min+max));
}
return 0;
}