Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- double y;
- double f(double x) { return ( 1/ (x*log(x)*log(x)));}
- double I(double a, double b, int n, double y) { return ((b - a) / (2 * n)*y); }
- int main() {
- int n;
- double a, b, dy, In;
- cin >> a >> b >> n;
- if (n > 1) {
- dy = (b - a) / n;
- y += f(a) + f(b);
- for (int i = 1; i < n; i++) { y += 2 * (f(a + dy * i)); }
- In = I(a, b, n, y);
- cout << In;
- }
- else { cout << "Wrong data"; }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement