Bob103

структура Point

May 15th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. double getS(int x1, int y1, int x2, int y2)
  7. {
  8. return sqrt( (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) );
  9. }
  10.  
  11. struct Point{
  12. int x;
  13. int y;
  14. };
  15.  
  16. int main()
  17. {
  18. int n;
  19. cin >> n;
  20. vector<Point>mas(n);
  21. for (int i = 0; i < n; i++) {
  22. cin >> mas[i].x >> mas[i].y;
  23. }
  24. double maxDistance = 0;
  25. int x1, y1, x2, y2;
  26. for (int i = 0; i < n; i++)
  27. {
  28. for (int j = i + 1; j < n; j++)
  29. {
  30. if (maxDistance < getS(mas[i].x, mas[i].y, mas[j].x, mas[j].y))
  31. {
  32. maxDistance = getS(mas[i].x, mas[i].y, mas[j].x, mas[j].y);
  33. x1 = mas[i].x;
  34. y1 = mas[i].y;
  35. x2 = mas[j].x;
  36. y2 = mas[j].y;
  37. }
  38. }
  39. }
  40. cout << "Dots:" << x1 << " " << y1 << " and " << x2 << " " << y2 << endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment