xzbrac.c

来自「Numerical Recipes Software 提供的算法子程序集」· C语言 代码 · 共 32 行

C
32
字号
/* Driver for routine zbrac */

#include <stdio.h>
#define NRANSI
#include "nr.h"

static float fx(float x)
{
	return bessj0(x);
}

int main(void)
{
	int succes,i;
	float x1,x2;

	printf("%21s %23s\n","bracketing values:","function values:");
	printf("%6s %10s %21s %12s\n","x1","x2","bessj0(x1)","bessj0(x2)");
	for (i=1;i<=10;i++) {
		x1=i;
		x2=x1+1.0;
		succes=zbrac(fx,&x1,&x2);
		if (succes) {
			printf("%7.2f %10.2f %6s %12.6f %12.6f \n",
				x1,x2," ",fx(x1),fx(x2));
		}
	}
	return 0;
}
#undef NRANSI
/* (C) Copr. 1986-92 Numerical Recipes Software . */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?