二分法,素数和单链表
15. 以下程序求方程的一个近似根。root函数采用二分法计算并返回方程f(x)=0在[a,b]内的一个近似根,main函数调用root函数求方程cos(x)=0在[0,3.14]内的一个近似根。试完善程序以达到要求的功能。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
#include<math.h>
double root(double a,double b,double(*f)(double))
{
double x,y;
if((19)) {
printf("There is no root between%......
阅读全文