Advertisement
ceva_megamind

Untitled

Oct 18th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. struct Point {
  8.     int x, y;
  9.  
  10.     Point(): x(0),y(0) {};
  11.     Point(int a, int b): x(a), y(b) {};
  12.  
  13.     Point operator -(const Point& p) {
  14.         return Point(x - p.x, y - p.y);
  15.     }
  16.    
  17.     float distance() {
  18.         return sqrt(x * x + y * y);
  19.     }
  20. };
  21.  
  22. int main()
  23. {
  24.     int n, a, b;
  25.     cin >> n;
  26.     double maxim = 0;
  27.     vector <Point> pnt (n);
  28.     for (int i = 0; i < n; ++i)
  29.     {
  30.         cin >> a >> b;
  31.         pnt[i] = Point(a, b);
  32.     }
  33.     for (int i = 0; i < n; ++i)
  34.     {
  35.         for (int j = i + 1; j < n; ++j)
  36.         {
  37.             float d = (pnt[i] - pnt[j]).distance();
  38.             if (d > maxim)
  39.                 maxim = d;
  40.         }
  41.     }
  42.     cout << setprecision(15) << maxim;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement