Advertisement
Hanaigi

Untitled

Nov 2nd, 2023
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int const N = 1000;
  4. int main()
  5. {
  6. int a = 4, b = 6, f = 0, A[N + 1], I1 = 0, I2 = 0, ch = 0, nh = 0;
  7. float h, x = 0;
  8. h = 0.2;
  9. for (int i = 0; i <= N; i ++ )
  10. {
  11. x += h;
  12. f = (2.5 * pow(x, 2) - 0.1) / (tan(x) + sin(x));
  13. A[i] = f;
  14. }
  15. for (int i = 1; i <= N - 1; i++)
  16. I1 += A[i];
  17. I1 += A[0] / 2 + A[N] / 2;
  18. I1 *= h;
  19. printf("%d\n", I1);
  20. for (int i = 0; i <= N; i++)
  21. {
  22. if (i % 2 == 0)
  23. ch += A[i];
  24. else
  25. nh += A[i];
  26. }
  27. I2 = h / 3 * (A[0] + A[N] + 4 * nh + 2 * ch);
  28. printf("%d", I2);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement