Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <locale>
  4. #include <math.h>
  5. using namespace std;
  6. float f(float x)
  7. {
  8. return (1 / sqrt(3+pow(x,2)));
  9. }
  10. float f2(float x, float y)
  11. {
  12. return abs( (2 * pow(x, 2) - 3) /( pow(pow((pow(y, 2) + 3),5),0.5)));
  13. }
  14. int main()
  15. {int i, n; float G,h,I,S=0; float t[4]; float M; float a = 0.4, b=1.2;
  16.  
  17. setlocale(LC_ALL, "rus");
  18.  
  19. t[0] = f2(a, a);
  20. t[1] = f2(a, b);
  21. t[2] = f2(b, a);
  22. t[3] = f2(b, b);
  23. M = t[1];
  24. for (i = 0; i < 4; i++)
  25. {
  26. if (M < t[i]) M = t[i];
  27. };
  28. M = ceil(M);
  29. G = sqrt((pow((b-a),3)*M)/0.006);
  30. cout << "Введите n > " << round(G) << endl;
  31. cin >> n;
  32. cout << endl;
  33. float *x = new float[n+1];
  34. float *y = new float[n+1];
  35. h = (b - a) / n;
  36. for (i=0;i<n+1;i++)
  37. {
  38. x[i] = a + i * h;
  39. };
  40. for (i = 0; i < n+1; i++)
  41. {
  42. y[i] = f(x[i]);
  43. };
  44. for (i = 1; i < n; i++)
  45. {
  46. S = S + y[i];
  47. };
  48. I = h * (((y[0]+y[n]) / 2) + S);
  49. cout << I << endl;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement