From 9d2a1b8d8475a68ca50e7f631b2bc9676e08e3b7 Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Thu, 28 Apr 2016 08:39:28 +0800 Subject: [PATCH] Create 1724.c --- QUSTOJ/1724.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 QUSTOJ/1724.c diff --git a/QUSTOJ/1724.c b/QUSTOJ/1724.c new file mode 100644 index 0000000..a0475bb --- /dev/null +++ b/QUSTOJ/1724.c @@ -0,0 +1,34 @@ +#include +#include +#include + +#define DUR 0.001 +double func(double x) +{ + return (2*x*x*x)-(4*x*x)+3*x-6; +} + +double dfs(double L, double Mid, double R) +{ + int t; + if(R-L < DUR) return R; + + if(func(L)*func(Mid) <=0) + { + t= dfs(L,(L+Mid)/2,Mid); + } + else if(func(Mid)*func(R) <=0) + { + t= dfs(Mid,(Mid+R)/2,R); + } + return t; +} + +int main() +{ + double a, b, c; + scanf("%lf,%lf",&a,&c); + b = (a+c)/2; + printf("x=%6.2f\n",dfs(a,b,c)); + return 0; +}