编个C语言程序,用热二分法求方程x^3+4x-10=0 在区间[1,2]内的根(精确到0.00001)

学习 时间:2026-04-03 19:34:07 阅读:3868
编个C语言程序,用热二分法求方程x^3+4x-10=0 在区间[1,2]内的根(精确到0.00001)

最佳回答

高贵的小笼包

失眠的白昼

2026-04-03 19:34:07

#include #include int main(int argc,char *argv[]){double a=1。0,b=2。0;double x;while(1){x=(a+b)/2;if (-0。00001 < pow(x,3)+4*x-10 && pow(x,3)+4*x-10 < 0。00001){break;}else if(pow(x,3)+4*x-10 < 0){a=x;}else if(pow(x,3)+4*x-10 > 0){b=x;}}printf("%f\n",x);printf("%f\n",pow(x,3)+4*x-10);system("PAUSE");return 0;}

最新回答共有2条回答

  • 可靠的汉堡
    回复
    2026-04-03 19:34:07

    #include #include int main(int argc,char *argv[]){double a=1。0,b=2。0;double x;while(1){x=(a+b)/2;if (-0。00001 < pow(x,3)+4*x-10 && pow(x,3)+4*x-10 < 0。00001){break;}else if(pow(x,3)+4*x-10 0){b=x;}}printf("%f\n",x);printf("%f\n",pow(x,3)+4*x-10);system("PAUSE");return 0;}

上一篇 帝王 用英文怎么说

下一篇 抛砖引玉的引是什么意思?