📄 d4r5.cpp
字号:
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
#include <stdlib.h>
#include <fstream.h>
#include <string>
double gammln(double xx)
{
int j;
float temp;
double cof[6],stp,half,one,fpf,x,tmp,ser;
cof[1] = 76.18009173;
cof[2] = -86.50532033;
cof[3] = 24.01409822;
cof[4] = -1.231739516;
cof[5] = 0.00120858003;
cof[6] = -0.00000536382;
stp = 2.50662827465;
half = 0.5;
one = 1.0;
fpf = 5.5;
x = xx - one;
tmp = x + fpf;
tmp = (x + half) * log(tmp) - tmp;
ser = one;
for (j = 1;j<=6;j++)
{
x = x + one;
ser = ser + cof[j] / x;
}
temp = tmp + log(stp * ser);
return temp;
}
double beta(double z, double w)
{
double temp;
temp = exp(gammln(z) + gammln(w) - gammln(z + w));
return temp;
}
void main()
{
//program d4r5
//driver for routine Beta
int i;
char text[20];
double w,z,value,nval;
const double pi = 3.1415926;
fstream fin;
fin.open("d:\\vc常用数值算法集\\data\\fncval.dat",ios::in);
while (strcmp(text,"Beta")!=0)
{
fin>>text;
}
fin>>text;
fin>>nval;
cout<<"Beta Function"<<endl;
fin>>text;
cout<<endl;
cout<<" w z Actual beta(w,z)"<<endl;
for( i = 1;i<=nval;i++)
{
fin>>w;
fin>>z;
fin>>value;
cout<<setw(5)<<w;
cout<<setw(8)<<z;
cout<<setw(16)<<value;
cout<<setw(16)<<beta(w,z)<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -