Bob103

дичь

Sep 27th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int funct(int number)
  5. {
  6. #include <iostream>
  7. #include <cmath>
  8.  
  9. using namespace std;
  10.  
  11. double otrezok(double x1, double y1, double x2, double y2);
  12. {
  13. double result;
  14. result = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
  15. return result;
  16. }
  17.  
  18. bool IsTriangle(double a, double b, double c);
  19. {
  20. double eps = 1e-3; // точность вычислений до одной тысячной
  21. return (b + c - a > eps) && (a + c - b > eps) && (a + b - c > eps);
  22. }
  23.  
  24. int main()
  25. {
  26. const int n = 4;
  27. double x[n], y[n], a, b, c;
  28. int count = 0;
  29. cout << "Input coords of points:" << endl;
  30. for (int i = 0; i < n; ++i)
  31. {
  32. cout << "Point " << i + 1 << endl;
  33. cout << "\tx" << i + 1 << ": ";
  34. cin >> x[i];
  35. cout << "\ty" << i + 1 << ": ";
  36. cin >> y[i];
  37. }
  38. for (int i = 0; i < n - 2; ++i)
  39. for (int j = i + 1; j < n - 1; ++j)
  40. for (int k = j + 1; k < n; ++k)
  41. {
  42. a = otrezok(x[i], y[i], x[j], y[j]);
  43. b = otrezok(x[j], y[j], x[k], y[k]);
  44. c = otrezok(x[i], y[i], x[k], y[k]);
  45. if (IsTriangle(a, b, c))
  46. ++count;
  47. }
  48. cout << "Number of triangles: " << count << endl;
  49. system("pause")
  50. }
Advertisement
Add Comment
Please, Sign In to add comment