xbessi1.c
来自「< C语言数值算法程序大全>>配套程序」· C语言 代码 · 共 37 行
C
37 行
/* Driver for routine bessi1 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NRANSI
#include "nr.h"
#include "nrutil.h"
#define MAXSTR 80
int main(void)
{
char txt[MAXSTR];
int i,nval;
float val,x;
FILE *fp;
if ((fp = fopen("fncval.dat","r")) == NULL)
nrerror("Data file fncval.dat not found\n");
fgets(txt,MAXSTR,fp);
while (strncmp(txt,"Modified Bessel Function I1",27)) {
fgets(txt,MAXSTR,fp);
if (feof(fp)) nrerror("Data not found in fncval.dat\n");
}
fscanf(fp,"%d %*s",&nval);
printf("\n%s\n",txt);
printf("%5s %12s %13s \n","x","actual","bessi1(x)");
for (i=1;i<=nval;i++) {
fscanf(fp,"%f %f",&x,&val);
printf("%6.2f %12.7f %12.7f\n",x,val,bessi1(x));
}
fclose(fp);
return 0;
}
#undef NRANSI
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?