1z

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define N 10
int main(){
int X[N] = {10, 12, 14, 35, 24, 55, 6, 7, 28, 9};
int Y[N] = {4, 7, 8, 9, 5, 23, 5, 66, 32, 43};
double maxDistance = 0;
int X1, X2, Y1, Y2;
for(int i=0; i<N-1; i++){
for(int j=i+1; j<N; j++){
double currentDistance = (X[j] - X[i])*(X[j] - X[i]) + (Y[j] - Y[i])*(Y[j] - Y[i]);
if(currentDistance > maxDistance){
maxDistance = currentDistance;
X1 = X[j];
X2 = X[i];
Y1 = Y[j];
Y2 = Y[i];
}
}
}
maxDistance = sqrt((X1 - X2)*(X1 - X2) + (Y1 - Y2)*(Y1 - Y2));
printf("maxDistance = %f\nX1 = %i, Y1 = %i\nX2 = %i, Y2 = %i", maxDistance, X1, Y1, X2, Y2);
getch();
return 0;
}