mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1724.c
This commit is contained in:
parent
4fbf326efa
commit
9d2a1b8d84
34
QUSTOJ/1724.c
Normal file
34
QUSTOJ/1724.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user