⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d4r28.cpp

📁 Visual C++ 常用数值算法集 源代码
💻 CPP
字号:
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
#include <stdlib.h>
#include <fstream.h>
#include <string>
#include <process.h>

double ex(double x)
{
	double r1,r2,r3,r4,r5,r6,t1,t2,t3,t4,s1,s2,s3,s4,temp,aaa,y,w;
    r1 = 0.00107857;
    r2 = -0.00976004;
    r3 = 0.05519968;
    r4 = -0.24991055;
    r5 = 0.99999193;
    r6 = -0.57721566;
    t1 = 8.5733287401;
    t2 = 18.059016973;
    t3 = 8.6347608925;
    t4 = 0.2677737343;
    s1 = 9.5733223454;
    s2 = 25.6329561486;
    s3 = 21.0996530827;
    s4 = 3.9584969228;
    if (x < 1.0)
	{
        aaa = (r1 * x + r2) * x + r3;
        temp = ((aaa * x + r4) * x + r5) * x + r6 - log(x);
	}
    else
	{
        y = (((x + t1) * x + t2) * x + t3) * x + t4;
        w = (((x + s1) * x + s2) * x + s3) * x + s4;
        temp = (y / w) / (exp(x) * x);
	}
	return temp;
}

void main()
{
    //program d4r28
    //driver for routine ex
    int i;
	char text[20];
    double nval,value,x; 
    const double pi = 3.1415926;
    fstream fin;
    fin.open("d:\\vc常用数值算法集\\data\\fncval.dat",ios::in);
    while ( strcmp(text,"Exponential")!=0 )
	{
      fin>>text;
	}
	fin>>text;
	fin>>text;
    fin>>nval; 
    cout<<"Exponential integral Ex "<<endl;
    fin>>text;
    cout<<endl;
    cout<<"    x            actual             Ex(x)"<<endl;
    for( i = 1; i<=nval; i++)
	{
        fin>>x;
		fin>>value;           
		cout<<setw(6)<<x;
        cout<<setw(18)<<value;
		cout<<setw(18)<<ex(x)<<endl;			          
    }
}

⌨️ 快捷键说明

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