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

📄 d3r6.cpp

📁 vc++常用数值算法集合
💻 CPP
字号:
#include "iostream.h"
#include "math.h"
#include "string.h"

char choose[10];

double funcl(double x)
{
    return sqrt(x) / sin(x);
}

double funcu(double x)
{
    double pi = 3.1415926;
    return sqrt(pi - x) / sin(x);
}

double funcinf(double x)
{
    return sin(x) / (pow(x, 2));
}

double funcend(double x)
{
    return exp(-x) / sqrt(x);
}

double func(double x)
{
    //dim choose as string
    if (strcmp(choose,"funcl")==0)
	{
		return funcl(x);
	}
    if (strcmp(choose,"funcu")==0)
	{
		return funcu(x);
	}
    if (strcmp(choose,"funcinf")==0)
	{
		return funcinf(x);
	}
    if (strcmp(choose,"funcend")==0)
	{
		return funcend(x);
	}
}

double inf(double x)
{
    return func(1 / x) / pow(x , 2);
}

void main()
{
    //program d3r6
    //driver for routine qromo
    double res1,res2,result,x1 = 0.0;
    double x2 = 1.5707963;
    double x3 = 3.1415926;
    double ainf = 1e+20;
    cout<<endl;
    cout<<"improper integrals:"<<endl;
    cout<<endl;
    strcpy(choose,"funcl");
    qromo(x1, x2, result, "midsql");
    cout<<"function: sqr(x)/sin(x)      interval: (0,pi/2)"<<endl;
    cout<<"using: midsql                result: ";
    cout<<result<<endl;
    cout<<endl;
    strcpy(choose,"funcu");    
    qromo(x2, x3, result, "midsqu");
    cout<<"function: sqr(pi-x)/sin(x)   interval: (pi/2,pi)"<<endl;
    cout<<"using: midsqu                result: ";
    cout<<result<<endl;
    cout<<endl;
	strcpy(choose,"funcinf");
    qromo(x2, ainf, result, "midinf");
    cout<<"function: sin(x)/x^2        interval: (pi/2,infty)"<<endl;
    cout<<"using: midinf                result: ";
    cout<<result<<endl;
    cout<<endl;
	strcpy(choose,"funcinf");
    qromo(-ainf, -x2, result, "midinf");
    cout<<"function: sin(x)/x^2        interval: (-infty,-pi/2)"<<endl;
    cout<<"using: midinf                result: ";
    cout<<result<<endl;
    cout<<endl;
	strcpy(choose,"funcend");
    qromo(x1, x2, res1, "midsql");
    qromo(x2, ainf, res2, "midinf");
    cout<<"function: exp(-x)/sqr(x)     interval: (0,infty)"<<endl;
    cout<<"using: midsql,midinf         result: ";
    cout<<(res1 + res2)<<endl;
}

⌨️ 快捷键说明

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