Initialize two arrays that specify n points with coordinates (X, Y) in a two-dimensional space. Describe a function that finds the distances between all points and displays them in a table.
Counts the distance only between two points. What is wrong in the code?
float alldist(int *x, int *y); int main() { int *x=new int [5] {1, 4, 6, 2, 1}; int *y=new int [5] {6, 7, 8, 9, 10}; cout << "Расстояние между всеми точками:" << alldist(x, y) << endl; } float alldist(int *x, int *y) { float d; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; i++) { d = sqrt(pow((x[i+1] - x[i]), 2) + pow((y[j+1] - y[j]), 2)); return d; } } }
x[i]andy[j]much more. Is it between what is the distance? - Igor