?? d3r6.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 + -