c# - Getting all the possible distances between points -


I have created a program to generate several points (the number given by the user)

Therefore, the program produces N see the image for an example, in that case it has 3 digits

I have to get all the possible distance between those villages (in this case the distance is: AB, AC, BC).

Points are stored in the same array (this digit x-coordinate and y-coordinate)

  list & lt; Villages & gt;   

I know that I am a new Pythagoras theorem, I just can not get prostitution loop rights.

I would think that you have a regular nested for-loop Want to

Something like this should be done for:

 For  (int i = 0; i & lt; village list.count; ++ i) {for (int j = I + 1; J & LT; Village list.Count; ++ J) {Distancefind (village list [i] villagelist [ja]); }}   

where distanceFunc you want to use, the implementation of that distance function and village list your list Village

The reason for this is that you will use the loop because you need an internal loop to start an element before the external loop (i + 1), and the forward loop does not let you easily Use the index that you are currently in (they allow you to access the element, but do not easily see your position in the array).

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -