Răspuns :
Răspuns:
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
const int NMAX = 30;
struct punct {
int x;
int y;
} puncte[NMAX];
int distanta( int x1, int y1, int x2, int y2 ) {
return ( sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) );
}
int main() {
ifstream fin( "date.in" );
int n, i, j, maxim, x1, x2, y1, y2;
fin >> n;
for ( i = 0; i < n; i ++ ) {
fin >> puncte[i].x >> puncte[i].y;
}
maxim = 0;
for ( i = 0; i < n; i ++ ) {
for ( j = i + 1; j < n; j ++ ) {
if ( distanta( puncte[i].x, puncte[i].y, puncte[j].x, puncte[j].y ) >= maxim ) {
maxim = distanta( puncte[i].x, puncte[i].y, puncte[j].x, puncte[j].y );
x1 = puncte[i].x;
x2 = puncte[j].x;
y1 = puncte[i].y;
y2 = puncte[j].y;
}
}
}
cout << x1 << ' ' << y1 << '\n' << x2 << ' ' << y2;
return 0;
}
Explicație: