Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. void f(float a, float b, float c) {
  10. float e = 0.000001;
  11. ofstream out("output.txt");
  12. vector<float> vx, vn, vs;
  13. int count = 0;
  14.  
  15. for (float x = a; x <= b; x += c) {
  16. float slag = (7 * x);
  17. int k = 1;
  18. float res = slag;
  19. int deg = 1;
  20. while (abs(slag) >= e) {
  21. deg = 2 * k + 1;
  22. slag *= -(49 * x * x);
  23. slag /= (deg * (deg - 1));
  24. k++;
  25. res += slag;
  26. }
  27. vx.push_back(x);
  28. vs.push_back(res);
  29. vn.push_back(k);
  30. count++;
  31. }
  32.  
  33. //*************НАЧАЛО ВТОРОГО ЗАДАНИЯ******************
  34.  
  35. out << "x = ";
  36. for (int i = 0; i < count; i++)
  37. out << setw(10) << vx[i];
  38. out << endl;
  39.  
  40. out << "n = ";
  41. for (int i = 0; i < count; i++)
  42. out << setw(10) << vn[i];
  43. out << endl;
  44.  
  45. out << "f = ";
  46. for (int i = 0; i < count; i++)
  47. out << setw(10) << vs[i];
  48. out << endl;
  49.  
  50. vector<float> vnx, vns;
  51.  
  52. for (int i = 0; i < count; i++) {
  53. vnx.push_back(vx[i]);
  54. if(vx[i] != vx[count - 1])
  55. vnx.push_back((vx[i] + vx[i + 1]) / 2);
  56. }
  57.  
  58. for (int i = 0; i < count; i++) {
  59. vns.push_back(vs[i]);
  60. if(vs[i] != vs[count - 1])
  61. vns.push_back((vs[i] + vs[i + 1]) / 2);
  62. }
  63. out << "x = ";
  64. for (int i = 0; i < count * 2 - 1; i++)
  65. out << setw(10) << vnx[i];
  66. out << endl;
  67.  
  68. out << "g1 = ";
  69. for (int i = 0; i < count * 2 - 1; i++)
  70. out << setw(10) << vns[i];
  71. out << endl;
  72.  
  73. //**********НАЧАЛО 3 ЗАДАНИЯ*************
  74. vector<float> v2s;
  75.  
  76. for (int i = 0; i < count * 2 - 1; i++) {
  77. v2s.push_back(vs[i]);
  78. float chis = 1, znam = 1;
  79. float L = 0;
  80. if(vx[i] != vx[count - 1]) {
  81. for (int j = 0; j < count; j++)
  82. chis *= (vnx[i + 1] - vx[i]
  83. v2s.push_back((vx[i] + vx[i + 1]) / 2);
  84. }
  85. out.close();
  86. }
  87.  
  88. int main() {
  89.  
  90. float a, b;
  91. float c;
  92.  
  93. cout << "a = ";
  94. cin >> a;
  95. cout << "b = ";
  96. cin >> b;
  97. cout << "c = ";
  98. cin >> c;
  99.  
  100. f(a,b,c);
  101. system("PAUSE");
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement