By DePaul Dimadis
Choose your prefered Language: greek_flag uk_flag

A serial file named points_2D.txt (for the exercise solution you need to create it through a text editor or through MS Excel) contains information that corresponds to mobile sites. In each line of the file, which concerns a space, there are two double numbers corresponding to its coordinates, and an integer value indicating the number of mobile devices present in the space, e.g.
5.27 7.92 19
3.75 8.57 25
Specify a structure named cell to manage the information of the points_2D.txt file. The members of the structure are the two cartesian coordinates () x, y and the number of movable devices m as defined previously.
Set a table of N-type cell structures (N = known).
Mobile devices will be serviced via base stations (antennas). Two points, A and B, are pre-selected to form base stations that can serve mobile devices at the same time. For these two points are known their AABBx surface coordinates, y, x, y given as constants at the beginning of the program. Due to the weakening of the signal from the base station to the mobile device, each base station can cover mobile devices up to a maximum distance from it.
The data in the table of structures will be entered by accessing the serial file points_2D.txt if the distances of each point i of the file from both points A and B, let A ,,, iBidd satisfy at the same time the relations: A ,, 10.0,10.0 iBidd≤≤. If the number of recordings in the file is greater than the N value then the extra records of the file will not be included in the table of structures. The following are requested (main () function:
1. import the data from the points_2D.txt file into the table of structures according to the above, checking the existence of the file (see the code below). If the file contains more than N points to find and display the number of file lines that satisfy the relationships: A ,, 10.0,10.0iBidd≤≤ and will not be included in the table of structures. If the file contains fewer than N lines, find and display the number of lines in the file that the structure table will contain.
2. Then find and display:
a. The total number of mobile devices that can be served by points A and B using the elements of the table of structures.
b. The mean value of the distances of all points in the table of structures from point A and from point B (ie 2 mean values).

FILE * fp;
errno_t err;
if (err = (fopen_s (& fp, filename, mode))! = 0)
{printf (\"error reading file .... \\ n\");
exit (1);
else // reading from file