Home > Back-end >  How for help in the C language array is used to calculate the distance between two coordinates
How for help in the C language array is used to calculate the distance between two coordinates

Time:11-25

Task 3.
Write a program that reads the coordinates of Max. 10 points (pairs of x and y) and
Saves those into a two - dimensional array: double points [10] [2] (the array can store 10
Pairs of x and y coordinates, i.e. for the data for 10 points). Then the program calculates the
The length of the short traveled through the points (from the first point to the last point).
The program USES functions provides for reading The coordinates of The points to an array...

ReadPoints (double [], [2], int size)
... And for printing the points...

Void printPoints (double [], [2], int size)
... And for calculating the short...

Double calculateDistance (double x1, double y1, double x2, double y2)

The short between two points (x1, y1) ja (x2, y2) is calculated by using The formula:
Under short equals root (x1, x2) ^ 2 + (y1, y2) ^ 2


Task 3.
Write a program that reads a maximum of coordinates, 10 points (x and y) and
Save the two-dimensional array: two point [10] [2] (array can store 10
X and y coordinates on that data at 10), and then calculates
(from the first point to the last point by point) length, the distance of the
The program using the function reads the coordinates of points to an array...
ReadPoints (double [], [2], int size)
And print the point...
PrintPoints (double [], [2], int size)
In order to calculate the distance...
Double calculateDistance (double x1, double y1, double x2, double y2)
Two (x1, y1) ja (x2, y2) distance calculation formula is:
Distance equals root (x1, x2) ^ 2 + (y1, y2) ^ 2

  • Related