d10r3.cpp

来自「工程算法 这是一个很有用的工程数值算法集锦」· C++ 代码 · 共 40 行

CPP
40
字号
#include <process.h>
#include <math.h>
#include <iomanip.h>
#include <iostream.h>

double func(double x)
{
	double t;
	t=bessj0( x);
	return t;
}

void main()
{
    //program d10r3
    //driver for routine zbrak
	int n,nbmax,i,nb;
	double x1,x2;
    n = 100;
    nbmax = 20;
    x1 = 1.0;
    x2 = 50.0;
    double xb1[20], xb2[20];
    nb = nbmax;
     zbrak(x1, x2, n, xb1, xb2, nb);
    cout<<endl;
	cout<<setprecision(4)<<setiosflags(ios::fixed);
    cout<<"Brackets for roots of Bessj0:"<<endl;
    cout<<endl;
    cout<<"  lower       upper      f(lower)    f(upper)"<<endl;
    for (i = 1; i<=nb; i++)
	{
        cout<< "root"<<" "<<i;
        cout<< setw(12)<<xb1[i];
        cout<< setw(12)<<xb2[i];
        cout<< setw(12)<<bessj0(xb1[i]);
        cout<< setw(12)<<bessj0(xb2[i])<<endl;
    }
}

⌨️ 快捷键说明

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