Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
44
Добавлен:
11.05.2015
Размер:
616 б
Скачать
#include <iostream>
#include  <stdio.h>
#include  <math.h>
#include  <stdlib.h>
#include <conio.h>

using namespace std;
double f(double x)
{
	double y;
	y = sin(2*x)*(exp(-x*x));
	return y;
}
int main ()
{
	int n,m,i;
	double a,b,e,h,sp,s,r;
	cout<<"vvedi a  b  e, \n";
	cin>>a>>b>>e;
	n=2; s=0;
m1: sp=s; m=n;
	n=n*2; h=(b-a)/n; s=f(a)+f(b);
	for (i=1;i<=m-1;i++)
	{
		r=(a+2*i*h);
		s= s+2*f(r);
		
	}

	
	for (i=0; i<=m-1; i++)
	{
		s= s+4*f(a+(2*i+1)*h);
	}
	s=s*h/3;
	if (fabs(sp-s)<e) cout<<"znach N "<<n<<"  znach S "<<s<<"\n";
	else goto m1;
	
	getch ();
	return 0;
}