Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //42
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n, firstPoint = 0, secondPoint = 0;;
- cin >> n;
- double X[n], Y[n], mx = 0;
- for(int i = 0; i < n; i++){
- cin >> X[i] >> Y[i];
- }
- for(int i = 0; i < n; i++){
- double r = sqrt(pow(X[i] - X[0], 2) + pow(Y[i] - Y[0], 2));
- if(r > mx){
- mx = r;
- firstPoint = i;
- }
- }
- for(int i = 0; i < n; i++){
- double r = sqrt(pow(X[i] - X[firstPoint], 2) + pow(Y[i] - Y[firstPoint], 2));
- if(r > mx){
- mx = r;
- secondPoint = i;
- }
- }
- cout << sqrt(pow(X[secondPoint] - X[firstPoint], 2) + pow(Y[secondPoint] - Y[firstPoint], 2));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment