Advertisement
labyyysosaaat

Untitled

Oct 21st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4. using namespace std;
  5. double y;
  6. double f(double x) { return ( 1/ (x*log(x)*log(x)));}
  7. double I(double a, double b, int n, double y) { return ((b - a) / (2 * n)*y); }
  8. int main() {
  9. int n;
  10. double a, b, dy, In;
  11. cin >> a >> b >> n;
  12. if (n > 1) {
  13. dy = (b - a) / n;
  14. y += f(a) + f(b);
  15. for (int i = 1; i < n; i++) { y += 2 * (f(a + dy * i)); }
  16. In = I(a, b, n, y);
  17. cout << In;
  18. }
  19. else { cout << "Wrong data"; }
  20. system("pause");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement