Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cmath>
  5. #include <iomanip>
  6. using namespace std;
  7.  
  8. #define forn3(a,n,m) for (int i=a; i<=n; i+=m)
  9. #define forn(i,n) for (int i=3; i<=n; ++i)
  10. //2 практика
  11. double rasst(double x, double y, double xx, double yy) {
  12. return (pow(xx - x, 2) + pow(yy - y, 2));
  13. }
  14. bool sravnim(double a, double b) {
  15. return (a < b);
  16. }
  17. /*
  18. //3 практика 5 раздел, задача 19
  19. double urav(double s) {
  20. return (sqrt(pow(s, 3) - 1) / sqrt(pow(s, 2) - 1));
  21. }
  22.  
  23. //3 практика, 6 раздел, задача 15
  24. int ix(int x) {
  25. return(x - 1);
  26. }
  27.  
  28. //5 практика, 4 раздел, задача 4
  29. double eps(double x, double e, int *n) {
  30. int i = 2;
  31. double a = x;
  32. double s = 1.0;
  33. while (fabs(a) >= e) {
  34. a = (pow(x, *n + i) * 1.0) / ((*n*1.0 + i) * pow(2, *n) *1.0);
  35. s += a;
  36. ++*n;
  37. ++i;
  38. }
  39. return s;
  40. }
  41. */
  42. int main() {
  43. setlocale(LC_ALL, "rus");
  44.  
  45.  
  46. cout << "2 практика, задача 18\nвведите координаты 3 точек\n";
  47. double x1, y1, x2, y2, x3, y3;
  48. cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  49. if (sravnim(rasst(x1, y1, x2, y2), rasst(x2, y2, x3, y3)))
  50. if (sravnim(rasst(x1, y1, x3, y3), rasst(x1, y1, x2, y2)))
  51. cout << "1 и 3";
  52. else cout << "1 и 2";
  53. else
  54. if (sravnim(rasst(x2, y2, x3, y3), rasst(x3, y3, x1, y1)))
  55. cout << "2 и 3";
  56. else cout << "3 и 1";
  57.  
  58. /*
  59. cout << "\n3 практика, 5 раздел, задача 19\nвведите границы отрезка и шаг\n";
  60. double a, b, h;
  61. cin >> a >> b >> h;
  62. forn3(a, b, h) {
  63. if (sqrt(pow(i, 2) - 1) > 0)
  64. cout << '\n' << urav(i);
  65. else
  66. cout << -1;
  67. }
  68.  
  69.  
  70. cout << "\n3 практика, 6 раздел, задача 15\nвведите x\n";
  71. int a1, b1, h1;
  72. cin >> a1 >> b1 >> h1;
  73. forn3(a, b, h) {
  74. if (ix(i) == 1)
  75. cout << 0;
  76. if (ix(i) < 1)
  77. cout << 1;
  78. if (ix(i) > 1)
  79. cout << -1;
  80. }
  81.  
  82.  
  83. cout << "\n4 практика, задача 16\nвведите номер элемента последовательности\n";
  84. double a11 = 1, a22 = 2, aaa;
  85. cin >> aaa;
  86. cout << 1 << " " << 2 << " ";
  87. forn(i, aaa) {
  88. cout << fixed<<setprecision(6)<<(i * a11 - a22) / (i + 1) << " ";
  89. a11 = a22;
  90. a22 = (i * a11 - a22) / (i + 1);
  91. }
  92.  
  93. cout << "\n 5 практика, 1 блок, 4 задача\n";
  94. cout << "введите количество элементов последовательности";
  95. int n1;
  96. double s1 = 1;
  97. cin >> n1;
  98. for (int i = 2; i <= n1; ++i) {
  99. s1 += 1.0 / i;
  100. }
  101. cout << s1;
  102.  
  103. cout << "\n 5 практика, 2 блок, 4 задача\n";
  104. int n2, x;
  105. double s2 = 0;
  106. cin >> n2 >> x;;
  107. for (int i = 1; i <= n2; ++i) {
  108. s2 += pow(x, 2 * (i - 1)) / pow(2 - 4 * (i - 1), 2);
  109. }
  110. cout << s2;
  111.  
  112. cout << "\n 5 практика, 3 блок, 4 задача\n";
  113. int e3, i3 = 1;
  114. double a = 1.0 / 2, s = 0;
  115. cin >> e3;
  116. while (fabs(a) >= e3) {
  117. s += a;
  118. ++i3;
  119. a = 1.0 / (i3 * (i3 + 1));
  120. }
  121. cout << s;
  122.  
  123. cout << "\n 5 практика, 4 блок, 4 задача\n";
  124. cout << "введите диапазон (от 0 до 0.99) и значение точности ";
  125. double a4, b4, e4;
  126. int n = 1;
  127. cin >> a4 >> b4 >> e4;
  128. cout << "\t" << " |\t" << " |\t" << "\n";
  129. for (double i4 = a4; i4 <= b4; i4 += 0.1) {
  130. cout << "\t" << i4 << " |\t" << eps(i4, e4, &n);
  131. cout << " |\t" << n << "\n";
  132. }
  133. */
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement