Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma hdrstop
- #pragma argsused
- #include <iostream.h>
- #include <math.h>
- #include <conio.h>
- double f(double x)
- {
- return exp(sin(x));
- }
- int main()
- {
- int n = 20;
- double I = 0;
- double I2 = 0;
- double E;
- cout << "E = ";
- cin>>E;
- double h = 1.0/n;
- do{
- I = I2;
- I2 = 0;
- h = 1.0/n;
- for (int i=0; i<n; i++)
- {
- I2+=f(i*h);
- }
- I2 = I2*h;
- n = n * 2;
- }
- while ( fabs(I-I2) > E);
- cout<<n<<endl;
- cout <<I<<endl;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement