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

📄 fuhua.cpp

📁 计算方法复化求积公式
💻 CPP
字号:
#include<iostream.h>
#include<math.h>
#define f(x) (sin(x))
#define m	 100
#define e	 0.00001
void main()
{
	int i;
	double n,a,b;
	double h,T1,T2,S;
	cout<<"Please input the begin and end of x (a<=x<=b):";
	cout<<"a=";cin>>a;
	cout<<"b=";cin>>b;
	n=m;
	h=(b-a)/n;
	for(i=1,S=0;i<=n-1;i++)
	{
		S=S+f(a+i*h);
	}
	T2=h*(1/2*f(a)+S+1/2*f(b));
	T1=T2+100;
	while((T1-T2)>3*e||(T1-T2)<-(3*e))
	{
		T1=T2;
		h=h/2;
		for(i=1,S=0;i<=n;i++)
		{
			S=S+h*f(a+(2*i-1)*h);
		}
		T2=T1/2+S;
		n=2*n;
	}
	cout<<"Output the T2:"<<T2<<endl;
	cout<<"Output the n:"<<n<<endl;
}



⌨️ 快捷键说明

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