Laitofai

42

Apr 8th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. //42
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n, firstPoint = 0, secondPoint = 0;;
  10.     cin >> n;
  11.     double X[n], Y[n], mx = 0;
  12.     for(int i = 0; i < n; i++){
  13.         cin >> X[i] >> Y[i];
  14.     }
  15.     for(int i = 0; i < n; i++){
  16.         double r = sqrt(pow(X[i] - X[0], 2) + pow(Y[i] - Y[0], 2));
  17.         if(r > mx){
  18.             mx = r;
  19.             firstPoint = i;
  20.         }
  21.     }
  22.     for(int i = 0; i < n; i++){
  23.         double r = sqrt(pow(X[i] - X[firstPoint], 2) + pow(Y[i] - Y[firstPoint], 2));
  24.         if(r > mx){
  25.             mx = r;
  26.             secondPoint = i;
  27.         }
  28.     }
  29.     cout << sqrt(pow(X[secondPoint] - X[firstPoint], 2) + pow(Y[secondPoint] - Y[firstPoint], 2));
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment