By DePaul Dimadis
Choose your prefered Language: greek_flag uk_flag

The problem of finding the closest pair of points is a geometric problem that involves finding two points in the space closest to one another.

A serial file named point3D.txt contains in each line the cartesian coordinates of a point in the three-dimensional space:
18.7 17.9 5.26
10.55 5.37 2.15
110.22 77.44 27.19
Specify a structure named point_3D to manage the coordinates of these points. The members of the structure are the three above-mentioned numbers, double type.
Set a table of structures of type point_3D, N-places (N = known).
The data in the table of structures will be imported by accessing the points3D.txt serial file.
Assume that the value of N exceeds the number of records in the file.
The following are requested (main () function:
1. import the data from the points3D.txt file into the table of structures in accordance with the above, checking the existence of the file (see the code below) and find and display the number of lines of the file that the table of structures.
2. Using all the elements in the structure table, find and display all pairs of points with the same minimum distance between them, with a precision of 10-3. Finally, you can also display the value of this minimum distance.
FILE * fp;
errno_t err;
if (err = (fopen_s (& fp, filename, mode))! = 0)
printf ("error reading file .... \ n");
exit (1);
else // reading from file